Deploy GitLab Container with Docker Compose


GitLab is a web-based platform for DevOps that provides a set of tools and features to support the entire software development lifecycle. It is often used for source code management, continuous integration, continuous delivery, and collaboration among development teams. GitLab is built on the Git version control system and extends its capabilities to cover various aspects of the software development process.


  • Minimum 2 core CPU and 4 GB memory required.
  • Basic knowledge of Docker.
  • Basic knowledge of Linux commands.
  • Up and running Docker.

To install Docker and docker compose on ubuntu 22.04 LTS, We can use the given link.

In this post, We will deploy GitLab container using Docker Compose on Ubuntu 22.04 LTS machine.

Step 1: Creating docker-compose.yml

Deploying GitLab using Docker Compose involves creating a docker-compose.yml file that defines the services, networks, and volumes required for GitLab. Below is a basic example to help you get started. Please note that this is a simplified configuration, and you may need to adjust it based on your specific requirements.

To create a docker-compose.yml

sudo nano docker-compose.yml

Copy and paste the followings configuration.

version: '3'

    image: gitlab/gitlab-ce:latest
    container_name: gitlab
    restart: always
      - "80:80"
      - "443:443"
      - ./gitlab/config:/etc/gitlab
      - ./gitlab/logs:/var/log/gitlab
      - ./gitlab/data:/var/opt/gitlab
      - gitlab-network

    driver: bridge

Save and exit from the nano text editor.

Step 2: Deploy GitLab Container

To deploy this GitLab service, follow these steps, Run the following command to start the GitLab container:

sudo docker-compose up -d

The -d flag runs the containers in the background, It will take few sec or mins to pull the image and deploy the GitLab.

After the services are started, you can access GitLab by navigating to http://localhost in your web browser. Follow the on-screen instructions to set up an initial administrator password.

Step 3: Initial Administrator Password

Configure your GitLab instance as needed. You can access the GitLab container to retrieve the initial administrator password by running:

docker exec -it gitlab cat /etc/gitlab/initial_root_password

Copy the password provided and use it to complete the setup in the web interface.

Step 4: Validate the Container

To check the running containers launched by Docker Compose, you can use the following command:

sudo docker-compose ps

This command provides a summary of the status of each service defined in your docker-compose.yml file. It shows information such as the service name, container ID, status, ports, and names.

Step 5: Logging

Some time we need to also check the real time logs, So we can use the given commands.

sudo docker-compose logs -f gitlab

Step 5: Destroy GitLab Container

To destroy (stop and remove) the GitLab container launched with Docker Compose, you can use the following command in the directory where your docker-compose.yml file is located:

sudo docker-compose down

This command stops and removes all the containers, networks, and volumes defined in your docker-compose.yml file.

The down command stops and removes the containers but retains the data volumes by default. If you want to remove the volumes as well, you can use the -v option:

Make sure you are in the correct directory containing your docker-compose.yml file when running these commands. This ensures that Docker Compose identifies the correct configuration file.

After running the docker-compose down command, you can use the docker-compose ps command to verify that the containers are no longer running. The output should be empty, indicating that no containers are currently running.

Remember that this command will stop and remove all the services defined in your docker-compose.yml file, not just the nexus service. If you only want to remove a specific service, you can specify the service name:

docker-compose down -v <service_name>

Replace <service_name> with the actual name of the service you want to remove.


We have successfully deployed GitLab container using Docker Compose on Ubuntu 22.04 LTS machine, If you still have questions, please post them in the comments section below.


Deploy GitLab Container with Docker Compose

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top