-
-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forward SSH Agent from Host into FPM Container #121
Conversation
I've not been this happy about a new feature being added to a tool I use in some time. Thanks for spending the time to figure this out! |
This doesn't seem to be working for me. However don't worry about looking into this just for me. But if anyone else reports this, it might be worth looking into.
|
When is the last time you pulled latest images? Could you run this and try again:
I ask this in order to make sure you have the changes from this commit in the image being used to create the containers on your system: a5df7fef |
@davidalger That did the trick! I was able to start an existing magento2 environment (without destroying the existing images via |
As a result of the changes implemented on #121, Docker Desktop 2.2.0.0 or later is required on macOS
Docker Desktop now allows users to access the host’s SSH agent inside containers as of Docker Desktop 2.2.0.0 (released 2020-01-21) and later.
Reference docker/for-mac#410 and https://docs.docker.com/docker-for-mac/release-notes/#docker-desktop-community-2200
Last month I began researching how to do this. It requires a bit of effort to work around permissions issues with forwarding the socket since it is owned by root in the VM used on macOS but FPM containers are running as uid 1000. To work towards solving this, I added
socat
to FPM images in Feburary and then implemented the necessary forward to the docker-entrypoint script: a5df7fefThis PR adds the necessary docker-compose configuration to successfully forward the ssh-agento into
php-fpm
andphp-debug
containers on both macOS and Linux hosts across Magento 1, Magento 2 and Laravel environment types.Simplest way to test this (and see it working) is to attempt a connection to Github (assuming your public key is authorized on Github that is):
Another way to see it work is to simply run
ssh-add -l
once inside a php-fpm container to list keys in the agent. For exampleNote that
agent refused operation
in the output of ssh-add is not indicative of a problem. As long as the keys in the agent on the host are listed and it's output isn't something such asCould not open a connection to your authentication agent
orError connecting to agent: No such file or directory
it means it's working as expected.