[GitLab CE Docker image] [Documentation] Setting ssh port to a custom port in docker run/compose needs some slight changes
Reference Links:
- https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/docker/README.md#expose-gitlab-on-different-ports
- https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/docker/README.md#install-gitlab-using-docker-compose
Docker compose file I use while starting the image via docker-compose up -d
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'myhostname.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://myhostname.com:30443'
gitlab_rails['gitlab_shell_ssh_port'] = 30022
ports:
- '30443:30443'
- '30022:30022'
volumes:
- '/Users/pandel/personal/local_gitlab_data/config:/etc/gitlab'
- '/Users/pandel/personal/local_gitlab_data/logs:/var/log/gitlab'
- '/Users/pandel/personal/local_gitlab_data/data:/var/opt/gitlab'
The documentation says that if we want gitlab to be exposed via ports which are not standard, then the above docker compose file should be used. But internally the sshd server still listens to port 22 which is not exposed to the host network.
$:git clone ssh://git@myhostname.com:30022/pandel/testing.git
Cloning into 'testing'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$:nc myhostname.com 30022
$:
Inside container
root@gitlab:/# lsof -i -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 25 root 3u IPv4 49977 0t0 TCP *:22 (LISTEN)
sshd 25 root 4u IPv6 49978 0t0 TCP *:22 (LISTEN)
nginx 458 root 7u IPv4 63552 0t0 TCP *:30443 (LISTEN)
nginx 458 root 8u IPv4 63553 0t0 TCP *:8060 (LISTEN)
I had to solve this by changing the docker compose file port configuration to
...
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://myhostname.com:30443'
gitlab_rails['gitlab_shell_ssh_port'] = 30022
ports:
- '30443:30443'
- '30022:22'
...
This ensured that the website still mentions the git clone link as ssh://git@myhostname.com:30022/pandel/testing.git
and the git clone too starts working normally.
My question is, am I doing something wrong here or does the documentation needs fixing ?