Skip to content

Instantly share code, notes, and snippets.

@ciiqr
Last active February 13, 2020 17:40
Show Gist options
  • Select an option

  • Save ciiqr/dc45f6a7188fed7abc5666c90c91bdcd to your computer and use it in GitHub Desktop.

Select an option

Save ciiqr/dc45f6a7188fed7abc5666c90c91bdcd to your computer and use it in GitHub Desktop.
docker build with ssh agent
DOCKER_BUILDKIT=1 docker build --ssh default -t test-build-ssh .
# syntax=docker/dockerfile:1.0-experimental
FROM ubuntu
RUN apt update && apt install -y openssh-client
RUN --mount=type=ssh ssh-add -l > /tmp/ssh-working-agent.out
# if you need ssh-agent when running also (only on docker for mac)
# source: https://docs.docker.com/docker-for-mac/osxfs/#ssh-agent-forwarding
docker run --mount "type=bind,src=$SSH_AUTH_SOCK,target=/run/host-services/ssh-auth.sock" -e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" -it test-build-ssh bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment