Using ssh-agent with docker on macOS

后端 未结 8 2141
不思量自难忘°
不思量自难忘° 2021-02-02 10:18

I would like to use ssh-agent to forward my keys into the docker image and pull from a private github repo.

I am using a slightly modified version of https://github.com/

8条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 10:39

    Since version 2.2.0.0, docker for macOS allows users to access the host’s SSH agent inside containers.

    Here's an example command that let's you do it:

    docker run --rm -it \
    -v /run/host-services/ssh-auth.sock:/ssh-agent \
    -e SSH_AUTH_SOCK="/ssh-agent" \
    my_image
    

    Note that you have to mount the specific path (/run/host-services/ssh-auth.sock) instead of the path contained in $SSH_AUTH_SOCK environment variable, like you would do on linux hosts.

提交回复
热议问题