Mount a secret during build
Use a secret file in one RUN without saving it in any layer. Pass it with --secret
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci
- tool
- buildkit4 commands
More buildkit commands
-
docker buildx build --ssh default -t <name> . # Dockerfile: RUN --mount=type=ssh git clone git@host:repoForward the host SSH agent into the build to clone private git repos. The key never gets into the image
-
docker buildx build --cache-to type=registry,ref=<reg>/cache,mode=max --cache-from type=registry,ref=<reg>/cache -t <reg>/<name> --push .Keep the full layer cache in a registry for CI. mode=max also caches intermediate stages
-
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txtReuse the package cache between builds without making layers bigger