Operations 7 min read

One-Click Automated Deployment of Spring Boot with Jenkins and Docker

This tutorial provides a step‑by‑step guide to set up a fully automated CI/CD pipeline on CentOS 7 that installs Docker, deploys Jenkins in a container, configures Maven and required plugins, creates a Jenkins job, builds a Spring Boot application with Dockerfile, and runs the resulting container, all with minimal pitfalls.

Code Ape Tech Column
Code Ape Tech Column
Code Ape Tech Column
One-Click Automated Deployment of Spring Boot with Jenkins and Docker

This article demonstrates how to create a complete Jenkins + Docker + Spring Boot one‑click automated deployment on a CentOS 7 host.

1. Install Docker

Update the system and remove any old Docker packages, then install the required utilities and Docker CE:

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 version

2. Install Jenkins

Run Jenkins (Blue Ocean) in a Docker container, exposing ports 8080 and 50000:

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/blueocean

Access Jenkins at http://{SERVER_IP}:8080, then unlock it by retrieving the initial admin password:

docker exec -it {JENKINS_CONTAINER} bash
cat /var/lib/jenkins/secrets/initialAdminPassword

Install the recommended plugins, then add Maven Integration, Publish Over SSH (optional), and Gitee plugin if using Gitee.

3. System Configuration

Configure Maven under Manage Jenkins → Global Tool Configuration and set the Maven installation path.

4. Create a Jenkins Job

Create a new freestyle project, configure the Git repository URL and credentials, and add a build step that runs Maven: clean install -Dmaven.test.skip=true Save the job.

5. Test the Build

Trigger a build, monitor the console output, and verify that a JAR file is produced.

6. Dockerfile for the Spring Boot Application

FROM jdk:8
VOLUME /tmp
ADD target/zx-order-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8888
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar","--spring.profiles.active=prd"]

7. Jenkins Job – Build and Run Docker Image

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:latest

After the job finishes, verify the container is running with docker ps and check its logs with docker logs zx-order. Access the application at http://{SERVER_IP}:8888.

The article concludes with a reminder to like, share, and follow the author for more Spring Boot and DevOps tutorials.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ci/cdmavenSpring BootJenkinsCentOS
Code Ape Tech Column
Written by

Code Ape Tech Column

Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.