buildkit
4 commands
4 shown
Registry build cache
Persist full layer cache in a registry for CI; mode=max caches intermediate stages
docker buildx build --cache-to type=registry,ref=<reg>/cache,mode=max --cache-from type=registry,ref=<reg>/cache -t <reg>/<name> --push .
Persistent cache mount in RUN
Reuse package cache across builds without bloating layers; survives between runs
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
Secret mount during build
Use a secret file in one RUN without baking it into any layer; pair with --secret
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci
SSH forward for private repos
Forward host SSH agent into build to clone private git; key never enters the image
docker buildx build --ssh default -t <name> . # Dockerfile: RUN --mount=type=ssh git clone git@host:repo
no commands match