Operations 7 min read

One-Click Jenkins + Docker + Spring Boot Deployment: Step-by-Step Guide

Learn how to set up a complete CI/CD pipeline on CentOS 7 by installing Docker and Jenkins, configuring Maven, creating a Jenkins job, and using a Dockerfile to automatically build and run a Spring Boot application with a single click.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
One-Click Jenkins + Docker + Spring Boot Deployment: Step-by-Step Guide

Environment

CentOS 7 with Git (Gitee) is used as the host environment.

Install Docker

Update yum, remove any old Docker packages, install required utilities, add the Docker CE repository, and install 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

Start Docker and enable it to start on boot, then verify the installation.

systemctl start docker
systemctl enable docker
docker version

Install Jenkins

Run the official Jenkins Blue Ocean image as a 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 http://{JENKINS_HOST_IP}:8080, unlock Jenkins with the password from cat /var/lib/jenkins/secrets/initialAdminPassword, and follow the setup wizard.

Install recommended plugins, then add the following additional plugins:

Maven Integration

Publish Over SSH (optional)

Gitee (if using Gitee, Git plugin is already included)

Create an administrator user and remember the credentials.

System Configuration

Navigate to Manage Jenkins → Global Tool Configuration and configure Maven installation.

Create Job

Create a new freestyle project, give it a name, and configure the following:

Source Code Management : select Git, enter the repository URL, and add credentials.

Build Triggers : enable the desired trigger (e.g., poll SCM or webhook).

Build : add a Maven build step with goals clean install -Dmaven.test.skip=true.

Save the job configuration.

Test

Click Build Now to start the job, then open the console output to verify that the Spring Boot JAR is produced. If the first build fails to download dependencies, run the build again.

cd /var/jenkins_home/workspace
ls

Run Project

Create a Dockerfile in the root of the Spring Boot project (no file extension) with the following content:

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 a post‑build step (or a separate job) that builds the Docker image and runs the container:

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

Verify the container is running with docker ps and view logs with docker logs zx-order. Access the application in a browser at http://{HOST_IP}:8888.

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.

Dockerci/cdDevOpsSpring BootJenkins
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.