Install GitLab using Docker on Debian

Aryan Arabshahi
September 01, 2021
Share:

GitLab is a web-based DevOps tool that provides a Git repository manager providing wiki, issue-tracking, continuous integration, and deployment pipeline features. Some other tools are doing this, but GitLab is definitely one the most popular ones. In this post, we're going to install it using Docker on Debian to have a private self-hosted GitLab. It has only two simple steps:

First of all, You have to install docker and docker-compose that we talked about it before here: How to install Docker on Debian

After that, create the “docker-compose.yml”:

version: '3.7'
services:
    gitlab:
        image: gitlab/gitlab-ce:latest
        container_name: gitlab
        hostname: gitlab.codewithcoffee.local
        restart: always
        volumes:
            - ./volumes/gitlab/config:/etc/gitlab
            - ./volumes/gitlab/logs:/var/log/gitlab
            - ./volumes/gitlab/data:/var/opt/gitlab
        ports:
            - 443:443
            - 80:80
            - "22:22"

Pull the image and run the service:

# Only pull the image
docker-compose pull
# You can pull the image and run the service at the same time
docker-compose up -d

As you see, GitLab is exposing port 22 which is the default SSH port number. So, before running the service, change the host SSH port number:

vim /etc/ssh/sshd_config

Change the Port from “22” to “2222” or anything else and restart the ssh service.

systemctl restart sshd

Now, You can run the service:

docker-compose up -d

GitLab has been installed and It's accessible directly with a browser. Also, You can use an “Nginx” web server to pass traffic to the GitLab service using a simple proxy pass if you want to.

Drink your coffee and ENJOY it :)