build secret
A password or token given to one build step without being saved in any image layer.
Secrets baked into layers can be extracted by anyone who pulls the image.
In more detail
docker build --secret id=npmtoken,src=./token plus RUN --mount=type=secret,id=npmtoken ... makes the file available to that RUN only. Copying a secret in and deleting it later does not work: the earlier layer keeps it, and ARG or ENV values are visible in image history.
Example
docker build --secret id=token,src=./token .Related terms
- secret — Any value that grants access, such as a password, access token or private key, and must be kept out of code and version control.
- whiteout file — A marker in a higher layer that says a file from a lower layer has been deleted.
- ARG — The Dockerfile instruction that declares a variable you can set at build time with --build-arg.
- RUN — The Dockerfile instruction that runs a command during the build and saves the result as a new layer.
Taught in
- RUN, SHELL And Efficient Layer Caching — Docker Architecture & Production Containers
- ARG, ENV, LABEL, EXPOSE And VOLUME — Docker Architecture & Production Containers
- Multi Stage Builds, Targets And Build Secrets — Docker Architecture & Production Containers
- Scan, Patch And Inspect The Software Supply Chain — Docker Architecture & Production Containers
- Build, Test And Promote The Same Image In CI — Docker Architecture & Production Containers