문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top