0

I'm trying to set up GitLab as a docker container in an internal server. Let's assume the server's IP is 10.10.10.10. Below is my docker-compose file that I use to bring up the container. I'm unable to access the http url via localhost:4080 (from a browser within the server) OR via the IP 10.10.10.10:4080. I'd like to understand what I'm missing here.

version: '2'

services:

  gitlab:
    image: gitlab-ee-img:12.0.9-ee.0
    container_name: gitlab
    restart: always
    hostname: 'localhost:4080'
    # environment:
    #   GITLAB_OMNIBUS_CONFIG: |
    #     # Add any other gitlab.rb configuration here, each on its own line
    #     # external_url 'https://gitlab.example.com'
    #     external_url 'http://127.0.0.1:4080'
    ports:
      - '4080:80'
      - '4443:443'
      - '4022:22'
    volumes:
      - '/data/gitlab/config:/etc/gitlab'
      - '/data/gitlab/logs:/var/log/gitlab'
      - '/data/gitlab/data:/var/opt/gitlab'
apocalypse
  • 5,764
  • 9
  • 47
  • 95
blueren
  • 2,730
  • 4
  • 30
  • 47

2 Answers2

1

Not entirely sure about if there's something else not working there but I'm fairly sure that the hostname: 'localhost:4080' block is not correct. It should be just the hostname without a port. Try to comment out that line and try without defining a hostname at all for testing.

src: https://docs.docker.com/compose/compose-file/#domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir

Stefano
  • 4,730
  • 1
  • 20
  • 28
  • Thanks for the answer. I happened to dig around a bit in the gitlab forums and found the answer. – blueren Sep 13 '19 at 13:45
0

For anyone hitting this SO question:

The answer is to NOT map a custom port on to 80 in docker. Instead, this will work:

version: '2'

services:

  gitlab:
    image: gitlab-ee-img:12.0.9-ee.0
    container_name: gitlab
    restart: always
    hostname: '10.10.10.10'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        # Add any other gitlab.rb configuration here, each on its own line
        # external_url 'https://gitlab.example.com'
        external_url 'http://10.10.10.10:4080'
        gitlab_rails['gitlab_shell_ssh_port'] = 4022
    ports:
      - '4080:4080'
      - '4443:443'
      - '4022:22'
    volumes:
      - '/data/gitlab/config:/etc/gitlab'
      - '/data/gitlab/logs:/var/log/gitlab'
      - '/data/gitlab/data:/var/opt/gitlab'

The reason is explained in this thread - Specifically, this answer

To summarize here (quoting the original answer),

The default port of gitlab is 80, but when you use the external_url clause, gitlab changes the ngnix port to which it is going to listen or resolve, it is not just an alias.

If you inside the container executes the command curl http://localhost, after having placed external_url http://10.10.10.10:4080, it will not answer for port 80, you can try with the command curl http://10.10.10.10:4080

blueren
  • 2,730
  • 4
  • 30
  • 47