1

I have a machine with ssh running on it. Now, I wanted to run the gitlab inside the docker container. So, followed the instructions mentioned here https://docs.gitlab.com/omnibus/docker/. The instruction says bind the container ssh port 22 with host machine's ssh port(22). I was unable to do this because port was already binded with openssh server in the host machine. So I binded the container's ssh port to some other port say 222 or so. Doing so gitlab got set-up but when I try to clone the project using ssh way I am not able to do.

Is there a way to fix this issue? what could be reason, I suspect it's because of the port mapping. I want to have the ssh running on my host machine, run the gitlab inside the container and should be able to use ssh way for code commit,clone and push.

3
  • Add examples of your attempts with outputs, please. Commented Jun 3, 2019 at 14:49
  • Can you run docker ps on your server and show us the port mapping? All SSH connections default to port 22 so you probably have to explicitly add the port number to the git remote URL Commented Jun 3, 2019 at 15:20
  • Up 2 minutes (healthy) 0.0.0.0:222->22/tcp, 0.0.0.0:9090->80/tcp, 0.0.0.0:444->443/tcp gitlab. This is the port mapping after docker ps command Commented Jun 3, 2019 at 15:48

1 Answer 1

1

Docker port mapping is one thing but you also need to adapt the gitlab rails configuration in gitlab.rb to specify the custom ssh port :

gitlab_rails['gitlab_shell_ssh_port'] = 222

and restart the container

Sign up to request clarification or add additional context in comments.

3 Comments

git clone [email protected]:sudhir/dummm.git. Anyway, that's how I was trying to clone dummy project. It keep asking for the password, I was keying the phassphrase for the my ssh private key.
let me try the above setting
Gitlab adapt automatically the clone url in your project with this setting enabled. Ex : ssh://git@host:222/project.git

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.