I've run into problems trying to support the ssh-agent SSH_AUTH_SOCK specifically with "Docker for Mac".
The problem appears to be due to osxfuse not supporting socket connections across the OS X Host / Docker Container boundary.
As the documentation states:
Socket files and named pipes only transmit between containers and between OS X processes – no transmission across the hypervisor is supported, yet.
So I can mount in the ssh-agent socket, it appears inside the container fine. However, accessing it via ssh-add -l always results in: "Could not open a connection to your authentication agent."
For example, I can find my SSH_AUTH_SOCK file on the OSX host (e.g.: /private/tmp/com.apple.launchd.abCDEfghiJ/Listeners)
Then, I can run a container using "Docker for Mac" by passing in the volume mount & environment variable arguments like: -v /private/tmp/com.apple.launchd.abCDEfghiJ:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent/Listeners
Inside the container, the socket appears as a socket owned by root. I'm running as root in the container & have rw access. However, ssh-add cannot communicate over the socket.
[root@62b57964834a ansible]# env | grep -i ssh SSH_AUTH_SOCK=/ssh-agent/Listeners [root@62b57964834a ansible]# ls -l $SSH_AUTH_SOCK srw-rw-rw- 1 root root 0 Feb 1 17:57 /ssh-agent/Listeners [root@62b57964834a]# whoami root [root@62b57964834a]# ssh-add -l Could not open a connection to your authentication agent.