DEV Community

Henrique Holtz
Henrique Holtz

Posted on • Edited on

How to run gitlab-ce (self-managed) on docker container [part 1]

Here we'll see how to run the gitlab-ce (community edition) self-managed on docker container (linux based). We'll use docker-compose too.

First we'll create a new variable GITLAB_HOME, in my case I used this command:

export GITLAB_HOME=$HOME/gitlab
Enter fullscreen mode Exit fullscreen mode

You can verify if the variable it's correctly run echo $GITLAB_HOME in your terminal.

After that, we'll create our files as docker-compose.yml. Choose one folder to it and let's start!

Now, create one file named root_password.txt, and put on it one string to use as the root password. In my case I fill with RootP@ssord123!.

Then, we can create our docker-compose.yml, you can use my template bellow:

version: '3.6'
services:
  web:
    image: 'gitlab/gitlab-ce:latest'
    container_name: gitlab_ce
    restart: always
    hostname: 'gitlab.henriqueholtz.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://gitlab.henriqueholtz.com'
    ports:
      - '80:80'
      - '443:443'
      - '22:22'
    volumes:
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'
    shm_size: '256m'
    secrets:
      - gitlab_root_password

  gitlab_docs:
    image: registry.gitlab.com/gitlab-org/gitlab-docs:latest
    container_name: gitlab_ce_docs
    hostname: 'https://docs.gitlab.henriqueholtz.com:4000'
    ports:
      - '4000:4000'

secrets:
  gitlab_root_password:
    file: ./root_password.txt
Enter fullscreen mode Exit fullscreen mode

Then we are ready to run our container, then run docker-compose up -d.

Note: If you want use the hostname above (ex: gitlab.henriqueholtz.com), you need to add it on the hosts config. Or we can use the localhost or 127.0.0.1.

Using https://localhost (default port, 443), we already can see the gitlab web interface, but with the 502 status code:

gitlab-ce at localhost with status code 502

The container can spend some minutes to stand up (for me something around 10 minutes). Meanwhile we can see the logs of our container with the command bellow:

docker logs gitlab-ce -f
Enter fullscreen mode Exit fullscreen mode

We can access our gitlab-docs at localhost:4000:

gitlab-ce docs at localhost:4000

Some minutes later, we can access our gitlab community edition self-managed, and see the login page: (ex: http://localhost)

Gitlab-ce at localhost:80 to login

Now, to access your own gitlab you can reset the root password of gitlab-ce

The official documentation to install gitlab-ce self-managed of gitlab: https://docs.gitlab.com/ee/install/docker.html

Thanks for reading, I see you later, in the next part!

Top comments (0)