If you are looking for a way to "mount" files, like -v
for docker run
, you can now use the --secret
flag for docker build
echo 'WARMACHINEROX' > mysecret.txt
docker build --secret id=mysecret,src=mysecret.txt .
And inside your Dockerfile you can now access this secret
# syntax = docker/dockerfile:1.0-experimental
FROM alpine
# shows secret from default secret location:
RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret
# shows secret from custom secret location:
RUN --mount=type=secret,id=mysecret,dst=/foobar cat /foobar
More in-depth information about --secret available on Docker Docs