You are here

Gitlab in a Docker container

logoA little bit more than one year ago, I started playing with Docker. I now run almost all server applications I use in containers: two Drupal web servers, a phpBB forum, a reverse proxy, a DNS server, a MineOS server for my son, etc. I have had the opportunity to investigate how to handle various requirements: data persistence, application update, microservice architecture, service dependency, etc. But I still consider myself as a naive beginner: the applications I have dockerized are for my personal use only. Consequently I've never been exposed to real-life constraints (large number of connections, security, high availability, etc.)

From time to time, I'm asked by some friends to help them, in my field of expertise[1], to solve some issues they face or to rapidly develop proofs of concept. Deliverables are source code and possibly some electronic schematics. Until recently, I have used email and file transfer to deliver those elements. And I have used a private version control system. Some weeks ago, I decided to spend some time in checking whether a dockerized GitLab could be a good solution to replace my archaic way of handling and sharing source code and schematics.

After some tests, I got the answer: yes! This article describes the few steps I followed to set up my configuration.


Detailed reference documentation is available. Adhering to it:

  • create directories that will contain persistent data. For me:
    • /var/www/runninggitlab/config
    • /var/www/runninggitlab/logs
    • /var/www/runninggitlab/data
  • create and start the container:
$ sudo docker run --detach \
--hostname <hostName> \
--publish <publicPort>:80 \
--name gitlab \
--restart always \
--volume /var/www/runninggitlab/config:/etc/gitlab \
--volume /var/www/runninggitlab/logs:/var/log/gitlab \
--volume /var/www/runninggitlab/data:/var/opt/gitlab \

A few words of explanation:

  • hostname allows you to choose the name of the container host
  • I use jwilder/nginx-proxy as reverse proxy. VIRTUAL_HOST environment variable is here for it.
  • publicPort has to be set to an available port. Reverse proxy will use it.
  • I prefer to have control on installed version, instead of getting latest one available on Docker Hub. That's why I use the 8.2.1-ce.0 tag.


Now that the container is started:

  • wait for it to be active
  • I use my own SMTP server to send emails. To configure GitLab to use it, I uncomment following lines in /var/www/runninggitlab/config/gitlab.rb:
external_url "http://<myGitLabURL>"
gitlab_rails['gitlab_email_from'] = '<fromEmail>'
gitlab_rails['gitlab_email_reply_to'] = '<replyToEmail>'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "<SMTPServerAddress>"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "<SMTPUserName>"
gitlab_rails['smtp_password'] = "<SMTPPassword>"
gitlab_rails['smtp_domain'] = "<SMTPDomain>"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'none'
  • restart the container
  • wait for it to be active again
  • log in, with user root and password 5iveL!fe. That's it!


To backup GitLab data, enter the container, and run the backup command:

$ sudo docker exec -it gitlab bash
# gitlab-rake gitlab:backup:create

Backup file is created in /var/www/runninggitlab/data/backups/ on the host system.

I'll soon automatize backup process. Stay tuned...

GitLab upgrade

Refer to related documentation. I followed it this morning, without any trouble.

GitLab + HTTP + SSH + reverse proxy

Check this article.

[1] For 25 years, I've developed systems in the field of what is today named IoT or M2M. My main expertise relates to designing and implementing (application-level) communication between connected objects and a central application. This encompasses bare-metal embedded software development, application-level protocol design and implementation, interfacing with various communication modules, some digital electronics, etc. Overall system-architecture design is part of my expertise as well.