GitLab Logo

Install GitLab with Docker

GitLab is a complete DevOps platform for managing Git repositories, running CI/CD pipelines, tracking issues, and much more. The official and most straightforward way to run a self-managed GitLab instance is via their Docker image.

High system requirements: GitLab is a resource-intensive application. We recommend a server with at least 4 CPU cores and 8 GB of RAM for a stable experience.

Step 1: Create the Docker Compose File

Log in to your server via SSH, create a directory for GitLab, and open the Compose file:

Create Directory and File
mkdir gitlab && cd gitlab && nano docker-compose.yml

Paste the following configuration into the file. You will customize the domain in the next step.

docker-compose.yml
version: '3.6' services: web: image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'gitlab.example.com' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'https://gitlab.example.com' ports: - '80:80' - '443:443' - '2222:22' volumes: - '$GITLAB_HOME/config:/etc/gitlab' - '$GITLAB_HOME/logs:/var/log/gitlab' - '$GITLAB_HOME/data:/var/opt/gitlab' shm_size: '256m'

Step 2: Configure Your Domain

Before starting GitLab, replace all instances of gitlab.example.com in the Compose file with your actual domain (e.g. gitlab.yourdomain.com). Also make sure your domain's DNS A record points to your server's IP address.

You also need to set the $GITLAB_HOME environment variable, which defines where GitLab stores its data. Run the following in the same directory as your Compose file:

Set GITLAB_HOME Variable
export GITLAB_HOME=$(pwd)

To make this persistent across reboots, add the line to your ~/.bashrc or ~/.profile.

Step 3: Start GitLab

Start the GitLab instance with the following command:

Start Docker Compose
docker compose up -d

Be patient: The first startup requires GitLab to initialize and configure itself. This can take 5 to 15 minutes or longer. The instance will not be accessible until this process is complete. You can monitor the status with docker ps.

Step 4: Retrieve the Initial Root Password

GitLab automatically generates a secure password for the initial root administrator account. Once the container is healthy, retrieve it with the following command:

Retrieve Root Password
docker compose exec -T web grep 'Password:' /etc/gitlab/initial_root_password > initial_password.txt

View the password with cat initial_password.txt. Make sure to save it somewhere safe and delete the file afterwards — it is automatically removed after 24 hours.

Step 5: First Login

Open your browser and navigate to the domain you configured (e.g. https://gitlab.yourdomain.com). Log in with the following credentials:

FieldValue
Usernameroot
PasswordThe password retrieved in Step 4

Change your root password immediately after the first login via the user profile settings.

Further Documentation

For advanced configuration, CI/CD setup, and administration guides, refer to the official GitLab documentation.