Docker – GitLab CE Docker – /etc/gitlab/gitlab.rb does not work as expected

dockergitlab

I installed the GitLab CE Docker image per these instructions. I'm running HTTP on a non-standard port while I experiment with it and ran into some strange problems trying to configure a different HTTP IP & port.

Per the instructions, I mapped the port with this section of the docker run command --publish 192.168.88.135:8083:80 (note this machine has multiple IPs so I want to map to 192.168.88.135 specifically).

Once the container is running I connect to a shell inside it and edit /etc/gitlab/gitlab.rb as described here and here, to

external_url "http://192.168.88.135:8083"

To reconfigure GitLab I then restart the container via docker restart gitlab. Once this is done I point my browser to http://192.168.88.135:8083, however the site is unreachable.

If I run docker inspect gitlab, sure enough the port is mapped as expected

"80/tcp": [
    {
        "HostIp": "192.168.88.135",
        "HostPort": "8083"
    }
]

What's really strange is, if I recreate the volume and container from scratch and don't touch /etc/gitlab/gitlab.rb, I can access GitLab via http://192.168.88.135:8083. Any idea what's going on? I'm leery to move my repositories to this setup until I understand!

Best Answer

The official documentation seems to be wrong as discussed here. If you want to run Gitlab in port 8083 you have to change the external_url configuration option in gitlab config.rb file and you have to set the publish option in your docker run like this: --publish 192.168.88.135:8083:8083.

I've tried to do what you want using port 8081 using the following docker run command in just one step:

sudo docker run --detach \
    --hostname gitlab.example.com \
    --publish 192.168.1.50:8081:8081 \
    --publish 192.168.1.50:2222:22 \
    --name gitlab \
    --env GITLAB_OMNIBUS_CONFIG="external_url 'http://gitlab.example.com:8081/'; gitlab_rails['lfs_enabled'] = true;" \
    --volume ~/Docker/gitlab/config:/etc/gitlab \
    --volume ~/Docker/gitlab/logs:/var/log/gitlab \
    --volume ~/Docker/gitlab/data:/var/opt/gitlab \
    gitlab/gitlab-ce:latest

After a couple of minutes you should see Gitlab running (it takes some time to populate the database and other bootstrap stuff). gitlab running

If you are not patient you may also see a 502, but that does only mean that gitlab is starting :)

Related Topic