Question

I installed gitlab in a container with docker, which already EXPOSE 22. When I ssh -vv git@host.com I can't access with ssh publickey, only password method works.

How can I get ssh access to an docker container?

Thanks.

Was it helpful?

Solution

Finally, I solved my problem.

sudo docker run -p 2222:22 -d something, this will redirect port 22 of the Container to 2222 of the HOST, then I can login to the Container with ssh host.com -p 2222.

OTHER TIPS

It depends on:

  • how you installed that openssh service within your docker container (see "Not able to connect to docker containers using SSH")
    See that more recent example (January 2014)

    # Install apache and ssh server
    RUN sudo apt-get install -y openssh-server apache2 postgresql-9.3
    RUN mkdir -p /var/run/sshd
    
  • if you do have a ~git/.ssh/authorized_keys file with the right public key in it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top