You can quickly set up your own GitLab instance, manage your repositories, and take advantage of its powerful features by installing GitLab CE with Docker. We’ll walk you through the steps of installing GitLab CE with Docker on Ubuntu 22.04, ensuring a smooth installation and configuration. We’ll also go over how to create your first project in GitLab. GitLab is a well-known web-based Git repository manager that offers a full DevOps platform.


Before you begin, make sure you have the following:

  1. An Ubuntu 22.04 server.
  2. Sufficient system resources, including disk space, RAM, and CPU, to run GitLab CE and Docker containers.

Disk Space:

  • GitLab CE: Set aside 10-20 GB of disk space for GitLab’s application data and repositories. This area may vary depending on the number and size of projects you intend to host.
  • Docker: Make sure you have enough disk space for Docker images and containers. Aim for at least 20 GB of free space for Docker.


  • GitLab CE: For optimal performance, allocate at least 4 GB of RAM. However, if you anticipate heavy usage or a large number of concurrent users, consider allocating more RAM to efficiently handle the load.
  • Docker itself does not require a lot of memory. However, it is recommended that you have at least 2 GB of RAM available for Docker to run smoothly. Keep in mind that the more containers you run at the same time, the more memory you may require.


  • GitLab CE requires a multi-core CPU with a clock speed of at least 2 GHz. The number of CPU cores required is determined by the anticipated load and the number of concurrent users. GitLab can handle concurrent requests more efficiently because it has multiple cores.
  • Docker is designed to make efficient use of available CPU resources. A CPU with multiple cores or threads is advantageous, especially if you intend to run resource-intensive containers or have a large number of containers running concurrently.

Step 1: Update the package index

To begin, run the following commands to update your Ubuntu system:

sudo apt update
sudo apt upgrade -y

It is important to note that running these commands with administrative privileges (sudo) is required because it allows the system to perform the necessary operations for updating and upgrading packages.

Step 2: Install Docker on Ubuntu 22.04

If your server doesn’t already have Docker installed follow these steps:

a. Install Docker dependencies:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

b. Change System’s SSH port:

Gitlab utilizes the default SSH port, which is in conflict with the system’s SSH port. For the best results, change the system’s default port.

To change the SSH port on your Ubuntu system, you’ll need to modify the SSH server configuration file:

Using a text editor, modify the SSH server configuration file. You can use the nano editor, for example, by running the following command:

sudo nano /etc/ssh/sshd_config

Look for the line that specifies the SSH port in the sshd_config file. It is usually commented out with a # symbol by default, indicating that the default port (port 22) is used. Remove the # symbol at the beginning of the line to uncomment it and change the default port number (22) with the desired port number. Choose a port number that is not commonly used or assigned to another service. For example, you can use 2233.

Save the changes and exit the text editor. In nano, you can do this by pressing Ctrl + X, then Y to confirm the save, and Enter to exit. Restart the SSH service for the changes to take effect. Use the following command:

sudo service ssh restart

c. Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

d. Add the Docker repository:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

e. Install Docker:

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io

f. Check Docker installation by running:

sudo docker run hello-world
How to Install GitLab CE with Docker on Ubuntu 22.04

Step 3: Install GitLab CE with Docker:

Now, let’s use Docker containers to install GitLab CE:

a. Pull the latest GitLab CE Docker image:

sudo docker pull gitlab/gitlab-ce:latest
How to Install GitLab CE with Docker on Ubuntu 22.04

b. Create a directory to store GitLab’s configuration and data:

sudo mkdir -p /srv/gitlab/config /srv/gitlab/logs /srv/gitlab/data

c. Run the GitLab CE Docker container:

sudo docker run --detach \
  --hostname YOUR_SERVER_IP \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
Run the GitLab CE Docker container:

Replace YOUR_SERVER_IP with your server’s IP address or domain name.

Step 4: Configure GitLab CE with Docker

a. Set a new password for your GitLab CE with Docker panel

  • Run the following command to access the GitLab container’s shell:
sudo docker exec -it gitlab /bin/bash
  • Once inside the container’s shell, run the following command to reset the root user’s password:
gitlab-rake "gitlab:password:reset"
  • You’ll be asked to enter the username for which you’d like to reset the password. Enter root as the username and hit the Enter key.
  • Following that, you should receive confirmation that the password reset was successful.
  • Enter exit and press Enter to exit the container’s shell.
reset GitLab CE with Docker password
  • Restart the Docker
sudo systemctl restart docker

b. Access GitLab CE with Docker web interface

Open your browser and enter http://YOUR_SERVER_IP or http://YOUR_DOMAIN_NAME.

Step 5: Creating Your First Project

Now that GitLab CE with docker has been installed and configured, let’s start working on your first project:

On the GitLab homepage, click on the “Create a project” button.

GitLab CE with Docker new project

Choose the desired project template

GitLab CE with Docker new template

Fill in the project details, such as the name, description, and visibility level.

You will be redirected to your new project once the importing process is completed.

1 Comment

Devair Luiz Moitim · January 21, 2024 at 3:26 PM

Worked perfectly. Thank you so much for sharing.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.