Docker CLI

Build secret input

Supplies a file input separately from the normal build context. Use synthetic data only here, with the source excluded from COPY context. Use no-cache for the positive synthetic exercise to require execution.

Formal Syntax & Structure

docker syntaxdocker
docker build --secret id=<id>,src=<file> [OPTIONS] PATH

Parameters & Attributes

NameTypeDescription
idstringMount identifier.
srcstringPath to reviewed synthetic file.
PATHstringBuild context.

Working Example

Example Snippetdocker
docker build --no-cache --load --network none --secret id=demo,src=demo.txt -t bm-v09-build-secrets:lab .
Docker Reference