Interview Prep/Docker/Dockerfile Instructions & Builds

How do you use SSH keys to clone a private repo during build?

IntermediateConceptDockerfile Instructions & Builds
Answer

Forward the agent via BuildKit's SSH mount; the key never lands in the image.

RUN --mount=type=ssh git clone [email protected]:org/private.git
docker build --ssh default .
All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds