fannheyward
fannheyward

Reputation: 19267

git ssh can't access to gitlab in a docker container

I installed gitlab in a container with docker, which already EXPOSE 22. When I ssh -vv [email protected] I can't access with ssh publickey, only password method works.

How can I get ssh access to an docker container?

Thanks.

Upvotes: 2

Views: 3667

Answers (2)

fannheyward
fannheyward

Reputation: 19267

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.

Upvotes: 2

VonC
VonC

Reputation: 1323065

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.

Upvotes: 0

Related Questions