Deploying Jenkins and GitLab with Docker Compose
This guide explains how to set up Jenkins and GitLab containers using Docker Compose, including the required compose files, startup commands, and steps to retrieve initial passwords for accessing the services.
1. Deploy Jenkins
Create a docker-compose.yml file with the following content:
version: '3.1'
services:
jenkins:
image: jenkins/jenkins:2.346.3
volumes:
- /data/jenkins/:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- /usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
ports:
- "8080:8080"
expose:
- "8080"
- "50000"
privileged: true
user: root
container_name: jenkins
environment:
JAVA_OPTS: '-Djava.util.logging.config.file=/var/jenkins_home/log.properties'Start the container in detached mode: docker-compose -f /root/docker-compose.yml up -d 2. Deploy GitLab
Create a docker-compose-gitlab.yml file with the following content:
version: '3.8'
services:
web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
# Add any other gitlab.rb configuration here, each on its own line
ports:
- '80:80'
- '443:443'
- '22:22'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
shm_size: '256m'Launch GitLab with: docker-compose -f /root/docker-compose-gitlab.yml up -d 3. Retrieve Initial Passwords
After the containers are running, locate the configuration directory and view the password files:
cd /config/
ls -l
cat initial_root_passwordThe commands list files such as gitlab.rb, gitlab-secrets.json, and initial_root_password, and display the generated root password needed to log into GitLab.
Images in the original article illustrate the Docker Compose output and the password file contents.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
