Running gitlab-docker on custom ports


I’m trying to use the gitlab/gitlab-ce docker image on a remote server which has already other services running on the ports #: 22,443, 80

For this reason, I run the container using the instruction:

docker run --detach \
    --hostname \
    --publish 8929:80 \
    --publish 2289:22 \
    --name gitlab-test \ 
    --restart always \
    --volume /srv/gitlab/config:/etc/gitlab \
    --volume /srv/gitlab/logs:/var/log/gitlab \
    --volume /srv/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest
  • log in by running:
docker exec -it gitlab-test /bin/bash
  • Edit the file /etc/gitlab/gitlab.rb to:
external_url ""
#external_url ""
gitlab_rails['gitlab_shell_ssh_port'] = 2289
  • Stop the container

  • Commit the changes

docker commit -m "changed htttp and shh port to 8929 2289" -a "epifelix" a631f515edc7 gitlab/gitlab-ce:latest
  • Restart the container

But when I try to log into my server with a browser pointing to:


I got:

This site can’t be reached
my.domain.ontheweb refused to connect.

Checking the connection
Checking the proxy and the firewall

I tried on my server to issue:

ufw allow 8929
ufw allow 2289

But still unable to load the page.
Have you any advice on how to fix this?

Am I modifying the correct file /etc/gitlab/gitlab.rb , which logs should I look into?

Is there any port of the debian installer for ubuntu 17.04?


1 Like

First try for gitlab, wanna use docker to test and same problem.
No firewall for the first test.

any update after your try ?

I got the same problem, but here’s what i did and now it’s working:

  1. changed /srv/gitlab/config/gitlab.rb:
    external_url "" # set the address of gitlab
    nginx['listen_port'] = 8929                   # make nginx to listen on the sam port as confgured in external_url
  2. gitlab-ctl reconfigure # reconfigure gitlab ecosystem
  3. Run:
    docker run --detach \      
       --hostname \
       --publish 8929:8929 \                                    # map the port which is usted by nginx to the same port i would like to use finally
       --publish 2289:22 \
       --name gitlab-test \ 
       --restart always \
       --volume /srv/gitlab/config:/etc/gitlab \
       --volume /srv/gitlab/logs:/var/log/gitlab \
       --volume /srv/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest

hope it works for you as well.



i’ve found this was corrected in the documentation, but another issue roll back to the wrong doc !
i wrote in the issues at gitlab documentation … waiting

The post is a little bit older but i struggled over some related problems.

You configured this:

--publish 8929:80 \
--publish 2289:22 \

What you are doing here is, you map the hosts port 8929 to the container port 80. Same with host:2289 to container:22.

But than you have changed GitLab’s ports in the container. That way the traffic on host:8929 is forwarded to port 80 in the container which is not used anymore.

You have to options.

  1. Configure the ports in GitLab uses in the container and expose them to the host
  2. Leave GitLab’s configuration as default and map the hosts ports like you have done before.

The second option does the configuratio in one place which is easier to manage.

add --env GITLAB_PORT=8929

this worked for me, thamk you :heart: