Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/314136-docker-composer-and-ssh-forwarding/
Share on other sites

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?

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.

@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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.