Deploying Jenkins with Docker Compose and Automating Build Pipelines
This guide explains how to replace the traditional manual jar deployment with an automated Jenkins pipeline using Docker Compose, covering Jenkins installation, container setup, unlocking the admin password, plugin configuration, global tool settings, and build‑release procedures.
Traditional method: Build the project into a JAR, upload the JAR to a Linux server, and run it with java -jar .
Automated method: Commit source code to a repository, set up a dedicated Jenkins server, configure JDK, Maven, and Git, let Jenkins pull the code, build a JAR, and run it via java -jar , Tomcat, or containerized approaches, optionally extending execution with custom shell scripts.
1. Deploy Jenkins with Docker Compose
Docker‑compose file ( docker-compose.yml ) 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
restart: always
container_name: jenkins
environment:
JAVA_OPTS: '-Djava.util.logging.config.file=/var/jenkins_home/log.properties'
Run the compose file:
docker-compose up -d
2. Create data directory for Jenkins
mkdir -p /data/jenkins
3. Unlock Jenkins
Find the container ID and open a shell:
docker ps
docker exec -it jenkins /bin/bash
Read the initial admin password:
cat /var/jenkins_home/secrets/initialAdminPassword
Use the displayed password to complete the Jenkins setup UI.
4. Install additional plugins (e.g., Publish Over SSH) via the Jenkins plugin manager.
5. Global configuration – set up JDK and Maven installations under "Global Tool Configuration".
6. Build and release – configure a pipeline or freestyle job to pull code, build the JAR, and deploy it using the chosen method (direct java -jar , Tomcat webapps, or container deployment).
The article also provides a list of recommended reading links for deeper Kubernetes and CI/CD topics.
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.