0

I'm trying to dockerize a flask app with git dependencies in its requirements :

#requirements.txt
git+ssh://git@bitbucket.org/mycompany/myproject.git@develop

So you have to get a valid ssh key to install requirements. Searching on answers, I found one that looks pretty simple with docker compose.

#docker-compose.yml
services:
  web:
    build: .
    command: python manage.py run -h 0.0.0.0
    volumes:
      ....
      - $SSH_AUTH_SOCK:/ssh-agent
    environment:
        SSH_AUTH_SOCK: /ssh-agent

But my build does not work, because it can't pull the repo in the requirements

  Host key verification failed.
  fatal: Could not read from remote repository.

When i try to ssh-add in the Dockerfile, another error appears.

Could not open a connection to your authentication agent.

echo $SSH_AUTH_SOCK on my machine shows this variable is not empty and point to an existing folder.

Am I missing something ? What does "Forwarding ssh agent" do exactly ?

tbarbot
  • 225
  • 1
  • 4
  • 18
  • 1
    The accepted answer to the linked question describes an approach that works on current Docker. `volumes:` only happen _after_ the image is built, so they don't help here, but there is support in newer versions of Docker for ssh-key forwarding. – David Maze Sep 23 '21 at 10:28
  • (Note that `docker-compose` doesn't support the `docker build --ssh` option from what I can tell, so you will need to `docker build` the image separately from the Compose flow.) – David Maze Sep 23 '21 at 10:31
  • alright this solution gives me 99 other problems but I guess it worked. thanks – tbarbot Sep 23 '21 at 12:03

0 Answers0