Have you managed to make it work? I use Docker for Mac (1.12.0-rc2-beta17 (build: 9779)) and tried many solutions but I always get the error: bind: Address already in use
docker run -it -v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK="$SSH_AUTH_SOCK" --rm ubuntu bash
root@2ef24e4b480d:/# echo $SSH_AUTH_SOCK
/private/tmp/com.apple.launchd.F1ULFbm6Mx/Listeners
root@2ef24e4b480d:/# ssh-add -l
Could not open a connection to your authentication agent.
root@2ef24e4b480d:/# eval $(`ssh-agent -a $SSH_AUTH_SOCK`)
bind: Address already in use
I implemented a solution to this problem using docker-ssh-agent-forward for using ssh-agent at runtime and committing intermediary images for builds (yes, docker build). This should be more robust than using socat for concurrent builds (socat can only handle single connections unless you are using fork which complicates things further) and more secure. It works great on Docker for Mac and Linux alike.
Can we get a link to github issues or other issue tracker around this issue? Are there any other workarounds available? docker-ssh-agent-forward is extremely unwieldy.
That works for Dockerfile and docker-compose if a user is root and with some adjustments in Dockerfile for non-root.
When a user is non-root in the image and we use it in docker-compose with a mounted socket in volume, as explained https://docs.docker.com/docker-for-mac/osxfs/#ssh-agent-forwarding
the issue is that socket is owned by root and not accessible by the inner user from the image.
Any potential solution with chown or chmod didn’t work.
The idea is not to use root when pulling private repos as dependencies in image build process and during development in docker-compose.yml.