Hostname container (Gitlab docker)

Hi guy
I have issue gitlab-ce build with docker, hope everybody help please.
I run gitlab

sudo docker run --detach --hostname gitlab.devopstraining.vn --publish 3080:80 --name gitlab_main --restart always --volume /srv/gitlab_main/config:/etc/gitlab --volume /srv/gitlab_main/logs:/var/log/gitlab --volume /srv/gitlab_main/data:/var/opt/gitlab \gitlab/gitlab-ce:latest

Because run hostname gitlab.devopstraining.vn when I click issue project (issue → boards) it redirect hostname:

Ex: gitlab.devopstraining.vn/root/a/-/issues/1 (true is 10.32.4.1111:3080root/a/-/issues/1)

I have tried to fix the hostname in a number of ways but with no success like:

Solution 1:
Exec to container gitlab change: external_url in file gitlab.rb when I edit:

external_url “http://10.32.4.111:3080

and gitlab is die, I change url ohter gitlab is running true, but it’s die issue because redirect hostname not found.

Solution 2:
I change config file container in
/var/lib/docker/container/<container_id>

Ang it’s not working when I change hostname to 10.32.4.111:3080 (address other is run)

Solution 3:
I run new container with image above
When run with hostname
Ex: docker run —hostname=“localhost:8080” -dp 8080:80 <image_name>
Container not working
When run non hostname container is run true

I hope set default hostname follow port built (3080) or set hostname to “10.32.4.111:3080” (address gitlab) and not create new container.

Anyone who has encountered this issue before can support me. thank all !!

First of all, do not exec into the container and edit files, unless you are doing it to test something or the file is on a volume and you don’t have right to edit the file otherwise. When you recreate the container you lose everything that you wrote on the container’s filesystem.

According to the documentation there could be two reasons why gitlab redirects you.

  1. Optional. Before you change the external URL, determine if you have previously defined a custom Home page URL or After sign-out path. Both of these settings might cause unintentional redirecting after configuring a new external URL. If you have defined any URLs, remove them completely.

If gitlab stores this information in a database, you might need to completely remove the container nd recreate it again after changing the confuguration.

I don’t really understand what you wanted to change here, but never do that! Do not edit anything in that folder unless you know exactly what you are doing because you can damage the filesystem and make Docker completely unusable.

Try not to guess when you are using parameters and check the help first:

docker run --help

As the name of the parameter indicates, it is a hostname and not a hostname and a port. That wiuld never work.