Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@asterbini
asterbini / gist:3f6f89c4fad71b3c079a132d08be2537
Last active March 10, 2022 18:52
Forward SSH authentication when building a Docker image
docker build --ssh default -t asterbini/image .
then in your Dockerfile you can do
RUN --mount=type=ssh git clone git@github.com:your-repo.git
@asterbini
asterbini / gist:96c4988e5236fcf85626ca128a564b8b
Last active March 10, 2022 18:48
forward ssh authentication inside a running docker container by mounting the SSH_AUTH_SOCKET
docker run --rm -ti \
-v $(SSH_AUTH_SOCKET):/ssh-socket -e SSH_AUTH_SOCKET=/ssh-socket \
--user $UID:$GROUPS \
asterbini/image \
bash