Step-by-Step Guide to Deploy a Spring Boot Application with Docker and Jenkins CI/CD
This tutorial walks through installing Docker and Jenkins on CentOS, configuring system settings, creating a Jenkins job to pull, build, and package a Spring Boot project, testing the pipeline, and finally running the application via Docker, providing complete commands and configuration details for a reliable CI/CD workflow.
This article presents a comprehensive, beginner-friendly guide to setting up a one‑click automated deployment pipeline for a Spring Boot project using Docker and Jenkins.
1. Install Docker
Update YUM, remove old Docker versions, install required utilities, add the Docker CE repository, and install Docker CE. Start Docker and enable it to run on boot, then verify the installation with docker version .
yum update yum remove docker docker-common docker-selinux docker-engine yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum install docker-ce systemctl start docker
systemctl enable docker docker version2. Install Jenkins
Run Jenkins in a Docker container, exposing ports 8080 and 50000, and mounting volumes for persistence.
docker run --name jenkins -u root --rm -d -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueoceanAccess Jenkins at http://{SERVER_IP}:8080 , unlock it using the password from cat /var/lib/jenkins/secrets/initialAdminPassword , and install the recommended plugins.
3. System Configuration
Install essential plugins such as Maven Integration, Publish Over SSH, and Gitee (if needed). Configure Maven under "Global Tool Configuration".
4. Create Jenkins Job
Create a new freestyle project, set up Git source control with repository URL and credentials, and add a build step that runs Maven goals (e.g., clean install -Dmaven.test.skip=true ).
clean install -Dmaven.test.skip=true5. Test the Build
Trigger the build, monitor console output, and ensure a JAR is produced without errors.
6. Run the Project
Write a Dockerfile in the Spring Boot project root to package the JAR into a Docker image and run it.
FROM jdk:8
VOLUME /tmp
ADD target/zx-order-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8888
ENTRYPOINT ["Bash","-DBash.security.egd=file:/dev/./urandom","-jar","/app.jar","--spring.profiles.active=prd"]In the Jenkins job, add build steps to stop/remove any existing container, build the new image, and run it:
cd /var/jenkins_home/workspace/zx-order-api
docker stop zx-order || true
docker rm zx-order || true
docker rmi zx-order || true
docker build -t zx-order .
docker run -d -p 8888:8888 --name zx-order zx-order:latestVerify the container is running with docker ps and check logs using docker logs . Finally, access the application via a browser.
The article includes screenshots for each step and ends with a note about optional paid IDE activation codes, which are unrelated to the technical guide.
Top Architecture Tech Stack
Sharing Java and Python tech insights, with occasional practical development tool tips.
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.