Connect to Gitlab on local Ubuntu server

I have a local Ubuntu 20.04 server we can connect to over SSH, no problem. Following the docker-compose instructions here, the container seem to run with these settings in docker-compose.yml:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      # external_url 'http://192.168.0.142:8181'
      # Add any other gitlab.rb configuration here, each on its own line
  ports:
    - '8181:8181'
    # - '443:443'
    # - '23:22'
  volumes:
    - '$GITLAB_HOME/gitlab/config:/etc/gitlab'
    - '$GITLAB_HOME/gitlab/logs:/var/log/gitlab'
    - '$GITLAB_HOME/gitlab/data:/var/opt/gitlab'

The server already has some web server running on port 80, hence the custom port. But trying to connect 192.168.0.142:8181 in the browser fails. What do I do wrong?

Is that external_url actually active in the gitlab configuration? It looks like it’s commented. What happens if you remove the hash (#)?

1 Like

Thanks for quick reply :slight_smile: The external_url is commented out, but I have also tried external_url '192.168.142:8181' and external_url '192.168.142' and external_url 'http://192.168.142:8181'with the same result.

These are the ports listed on docker ps command:

22/tcp, 0.0.0.0:443->443/tcp, 80/tcp, 0.0.0.0:8181->8181/tcp

I think I see it, the external address can be listening on 8181, but in the container, the gitlab workhorse listens on the default port, so in the containr port 8181 is not used.
You probably should use gitlab_workhorse[‘listen_addr’] = “0.0.0.0:8181” or use the default port in your compose file:
ports:

  • ‘8181:8000’
    (I believe 8000 is default)

Sorry for the crappy formatting :wink:

1 Like

Thanks, I tried setting

  ports:
    - '8000:80'

in docker-compose.yml and

gitlab_workhorse[‘listen_addr’] = “0.0.0.0:8181”

in /etc/gitlab/gitlab.rb. Still I can’t connect via browser…

Another attempt. I tried setting

gitlab_workhorse[‘listen_addr’] = “0.0.0.0:8000”

in /etc/gitlab/gitlab.rb, and now I get an

502 error
Whoops, GitLab is taking too much time to respond.

when I connect to 192.168.0.142:8000. So the container seem to be serving right?

I solved it. Here are the correct combinations of parameters, hopefully of assistance for someone else having port 80 busy doing something else than serving Gitlab.

First I set external_url 'http://192.168.0.142', no ports necessary as implied in docs.

Then set

  ports:
    - '8000:80'

where the point is that 8000 is the port to apply to the external URL, e.g. `192.168.0.142:8000’ in the browser. Docker listens to port 80, and does not know about port 8000 or what you choose.

This worked, thanks to @bartj for pointing me in the right direction. I did try the workhorse setting in gitlab.rb but it turned out to not be necessary.

Last tip when connecting to Gitlab: wait until the Docker image status from docker ps shows healthy, that took one minute after restarting on my server.

My working docker-compose.yml:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'http://192.168.0.142'
      # Add any other gitlab.rb configuration here, each on its own line
  ports:
    - '8000:80'
    # - '443:443'
    # - '23:22'
  volumes:
    - '$GITLAB_HOME/gitlab/config:/etc/gitlab'
    - '$GITLAB_HOME/gitlab/logs:/var/log/gitlab'
    - '$GITLAB_HOME/gitlab/data:/var/opt/gitlab'