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 .

tool
buildkit4 commands
tags
buildkitciperformancecloud

More buildkit commands

  • RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt

    Reuse package cache across builds without bloating layers; survives between runs

  • RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci

    Use a secret file in one RUN without baking it into any layer; pair with --secret

  • docker buildx build --ssh default -t <name> . # Dockerfile: RUN --mount=type=ssh git clone git@host:repo

    Forward host SSH agent into build to clone private git; key never enters the image

all 4 buildkit commands