Could not open a connection to your authentication agent.
I am following the approach of mounting the $SSH_AUTH_SOCK as a volume, but doing so with compose.
I solved it using whilp/ssh-agent, though you should note that this is not using SSH_AUTH_SOCK
directly and requires an additional long running container. I'll integrate this approach into docker-rails for ease of use.
Start a long running container
docker run -d --name=ssh-agent whilp/ssh-agent:latest
Add your key
docker run --rm --volumes-from=ssh-agent -v ~/.ssh:/ssh -it whilp/ssh-agent:latest ssh-add /ssh/id_rsa
List your keys
docker run --rm --volumes-from=ssh-agent -v ~/.ssh:/ssh -it whilp/ssh-agent:latest ssh-add -L
bash into a container and check the key with ssh -T git@bitbucket.org
My yaml looks like:
web:
build: .
working_dir: /project
ports:
- "3000"
environment:
# make ssh keys available via ssh forwarding (see volume entry)
- SSH_AUTH_SOCK=/ssh-agent/socket
volumes_from:
# Use configured whilp/ssh-agent long running container for keys
- ssh-agent
The previous accepted answer using whilp/ssh-agent did not work for me for some reason (it worked before but since last changes it doesn't and I don't know why) so I created my own agent container:
docker-ssh-agent
based on minimal alpine:3.4
base image. So anyone still having trouble with this on OSX, check the README
it's now really easy to get it up and running!