maxxd Posted October 29, 2021 Share Posted October 29, 2021 Not sure what's the best place for this, so mods please feel free to move it somewhere more appropriate. I'm having literally no luck forwarding the SSH agent from my host machine to my docker images. I'm trying to set up an image that can use composer to pull several private bitbucket repositories. My docker-compose file includes a composer:2 service, shares volumes with my main app service, sets an environment variable SSH_AUTH_SOCK to /ssh-auth.sock, and mounts that volume to /ssh-auth.sock in the built container. No dice. After several days of not being able to do it via docker-compose I copied and pasted the exact code from the official docker Composer image: eval $(ssh-agent); \ docker run --rm --interactive --tty \ --volume $PWD:/app \ --volume $SSH_AUTH_SOCK:/ssh-auth.sock \ --env SSH_AUTH_SOCK=/ssh-auth.sock \ composer install and tried it without docker-compose; I got the same please make sure you have access to your private bitbucket repository error as I get in my compose file. I know this can work, but every example of it working doesn't actually work in my case so I assume I'm missing something... Anybody have any ideas or advice? Quote Link to comment https://forums.phpfreaks.com/topic/314136-docker-composer-and-ssh-forwarding/ Share on other sites More sharing options...
requinix Posted October 29, 2021 Share Posted October 29, 2021 You on a Mac? Is the $SSH_AUTH_SOCK path correct? I can find a number of comments talking about how mounting $SSH_AUTH_SOCK doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/314136-docker-composer-and-ssh-forwarding/#findComment-1591534 Share on other sites More sharing options...
maxxd Posted October 29, 2021 Author Share Posted October 29, 2021 I am on a mac and I believe the path is correct. I've seen ssh-agent as the volume mount and tried that as well, but still nada. The one thing that's been consistent in my searching is the environment variable name - were the comments you saw about that or the mount path? Quote Link to comment https://forums.phpfreaks.com/topic/314136-docker-composer-and-ssh-forwarding/#findComment-1591544 Share on other sites More sharing options...
requinix Posted October 29, 2021 Share Posted October 29, 2021 The path. They provided concrete paths instead of using the SSH_AUTH_SOCK variable, suggesting either the variable was wrong or there are multiple socks and only one works. Quote Link to comment https://forums.phpfreaks.com/topic/314136-docker-composer-and-ssh-forwarding/#findComment-1591549 Share on other sites More sharing options...
maxxd Posted October 29, 2021 Author Share Posted October 29, 2021 Well crap. Back to Google - thanks, requinix! Quote Link to comment https://forums.phpfreaks.com/topic/314136-docker-composer-and-ssh-forwarding/#findComment-1591583 Share on other sites More sharing options...
gizmola Posted October 31, 2021 Share Posted October 31, 2021 How about just copying a .composer/Auth.json file into the docker container, and using composer inside the php container to do your composer install? A good way to do it is to use docker-compose run --rm .... for things like composer installs or frameworks CLI utilities you might need. I figured out the ins and outs of bitbucket for private repos with composer and wrote about it here. Quote Link to comment https://forums.phpfreaks.com/topic/314136-docker-composer-and-ssh-forwarding/#findComment-1591612 Share on other sites More sharing options...
maxxd Posted October 31, 2021 Author Share Posted October 31, 2021 @gizmola - I am actually copying a composer.json file into the container and trying to run it, but it points to private bitbucket repositories and it's there that I'm running into issues. Thanks for the link and I'll let you know how it goes! Quote Link to comment https://forums.phpfreaks.com/topic/314136-docker-composer-and-ssh-forwarding/#findComment-1591618 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.