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

Taught in

References