buildkit commands

4 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 4 shown

  • docker buildx build --cache-to type=registry,ref=<reg>/cache,mode=max --cache-from type=registry,ref=<reg>/cache -t <reg>/<name> --push .

    Persist full layer cache in a registry for CI; mode=max caches intermediate stages

    ci · performance · cloud

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

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

    performance · ci

  • 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

    secrets · security

  • 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

    secrets · security · network