Configuring the External URL for GitLab in Docker

A NAS server was installed at home, and a Docker was installed on NAS, so a lot of in-house services were made to run on Docker.

But there was a problem in setting GitLab, and after a few changes, this was a very simple approach.

Let's get to the point. Most services are Web-based and require exposure to 80 ports. There are many services on Docker, and the IP shared mainframe is fine, but the port must be specified and then map to the 80 ports in the container.

For example:

# docker run --detach                       \
    -p 11443:443 -p 11480:80 -p 11422:22    \
    --name gitlab                           \
    --restart always                        \
    -v /gitlab/config:/etc/gitlab           \
    -v /gitlab/logs:/var/log/gitlab         \
    -v /gitlab/data:/var/opt/gitlab         \
    gitlab/gitlab-ce

However, in GitLab, once the project has been established, the “cloning” of the project does not automatically provide a suitable address, but only gives it:

http://b483cf8abf26/some_projects/project.git

It's disgusting. It's not working!

According to a number of online articles, it was said to have been modified/etc/gitlab/gitlab.rbMediumexternal_urlThat line, on it. For example:

external_url "http://192.168.1.114:11480"

But once the changes are applied:

gitlab-ctl reconfigure

The service can't get through.

What happened? Actually, this..external_urlOnce you have a port, the 80-port service will be changed to the set port. So, as set when the container was created,-p 11480:80It's definitely not working.

Change the port map of the container, direct.-p 11480:11480Okay. Also, this GitLab mirror still has an 8080 port inside, so it's best not to use it, or to configure it./etc/gitlab/gitlab.rbDocuments:

unicorn['port'] = 8800

This unicorn port configuration was not tested, but was taken as an extract from the notes.

It's a good setup.external_urlIt's just the first step, the project.克隆Medium使用HTTP克隆The address in it.使用SSH克隆It's not normal. It's wrong. How? Continue Configure/etc/gitlab/gitlab.rbDocuments:

gitlab_rails['gitlab_shell_ssh_port'] = 11422

All right, reset, reset Gitlab:

gitlab-ctl reconfigure
gitlab-ctl restart

There's no need to restart here. There's no need to do more. After that, the addresses in the clones should be normally available.

Hey, B., we can check the port information:

# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 localhost:9229          0.0.0.0:*               LISTEN
tcp        0      0 localhost:9236          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8060            0.0.0.0:*               LISTEN
tcp        0      0 localhost:9168          0.0.0.0:*               LISTEN
tcp        0      0 localhost:9187          0.0.0.0:*               LISTEN
tcp        0      0 localhost:9090          0.0.0.0:*               LISTEN
tcp        0      0 localhost:9093          0.0.0.0:*               LISTEN
tcp        0      0 localhost:9121          0.0.0.0:*               LISTEN
tcp        0      0 localhost:8154          0.0.0.0:*               LISTEN
tcp        0      0 localhost:8155          0.0.0.0:*               LISTEN
tcp        0      0 localhost:8153          0.0.0.0:*               LISTEN
tcp        0      0 localhost:8150          0.0.0.0:*               LISTEN
tcp        0      0 localhost:8151          0.0.0.0:*               LISTEN
tcp        0      0 localhost:8092          0.0.0.0:*               LISTEN
tcp        0      0 localhost:8082          0.0.0.0:*               LISTEN
tcp        0      0 localhost:8080          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:11480           0.0.0.0:*               LISTEN
tcp        0      0 localhost:3000          0.0.0.0:*               LISTEN
tcp        0      0 :::22                   :::*                    LISTEN
tcp        0      0 :::9094                 :::*                    LISTEN
udp        0      0 :::9094                 :::*
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  2      [ ACC ]     STREAM     LISTENING     5584197 /var/opt/gitlab/gitaly/gitaly.socket
unix  2      [ ACC ]     STREAM     LISTENING     5588069 /var/opt/gitlab/gitaly/run/gitaly-306/sock.d/ruby.1
unix  2      [ ACC ]     STREAM     LISTENING     5584198 /var/opt/gitlab/gitaly/run/gitaly-306/sock.d/intern
unix  2      [ ACC ]     STREAM     LISTENING     5573442 /var/opt/gitlab/gitaly/run/gitaly-306/sock.d/ruby.0
unix  2      [ ACC ]     STREAM     LISTENING     5591350 /var/opt/gitlab/postgresql/.s.PGSQL.5432
unix  2      [ ACC ]     STREAM     LISTENING     5609652 /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket
unix  2      [ ACC ]     STREAM     LISTENING     5591983 /var/opt/gitlab/gitlab-workhorse/sockets/socket
unix  2      [ ACC ]     STREAM     LISTENING     5589222 /var/opt/gitlab/redis/redis.socket

Because..external_urlGitLab is completely useless.80Port, yes.11480.

GitLab would actually specify an internal port according to the port of the external address.