Docker Buildx Cheat Sheet/Forward SSH agent during build

Forward SSH credentials into the build for private Git access.

Section: Buildx Build Workflows

Forward SSH agent during build

bash
bash
docker buildx build --ssh default -t myapp:dev .
Explanation

Useful when a build clones private repositories.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Buildx Build Workflows
Pass build secret
Pass a secret into the build without baking it into layers.
OpenIn sheetbashsame section
Build with Buildx
Build using Buildx and BuildKit.
OpenIn sheetbashsame section
Build and load into local daemon
Build and load the result into the local Docker image store.
OpenIn sheetbashsame section
Build and push directly
Build and push the image directly to a registry.
OpenIn sheetbashsame section
Build multi-platform image
Build and publish a multi-platform image.
OpenIn sheetbashsame section
Build target stage with Buildx
Build a specific stage using Buildx.
OpenIn sheetbashsame section