One‑Click Jenkins + Docker + SpringBoot Deployment: Step‑by‑Step Guide
This tutorial walks you through a complete one‑click Jenkins, Docker, and SpringBoot automated deployment on CentOS, covering environment preparation, Docker and Jenkins installation, plugin configuration, job creation, build testing, and running the packaged application in a Docker container.
This article demonstrates a comprehensive one‑click Jenkins + Docker + SpringBoot automated deployment, detailing environment setup, Docker installation, Jenkins installation, system configuration, job creation, build testing, and running the project.
Install Docker
Update yum packages: yum update Remove old Docker versions (if any):
yum remove docker docker-common docker-selinux docker-engineInstall required utilities:
yum install -y yum-utils device-mapper-persistent-data lvm2Add Docker CE repository:
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repoInstall Docker CE (latest stable): yum install docker-ce Start Docker and enable on boot:
systemctl start docker
systemctl enable dockerVerify installation:
docker versionInstall Jenkins
Pull and run the Jenkins Blue Ocean image:
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 and wait for initialization.
Unlock Jenkins:
docker exec -it {JENKINS_CONTAINER} bash
cat /var/lib/jenkins/secrets/initialAdminPasswordInstall the recommended plugins and create an admin user.
System Configuration
Install required plugins: Maven Integration, Publish Over SSH (optional), Gitee (if using Gitee), etc.
Configure Maven in Manage Jenkins → Global Tool Configuration and set up Maven installation.
Create Jenkins Job
New Item → Freestyle project.
Source Code Management → Git: provide repository URL and credentials.
Build Steps → Invoke top‑level Maven target: clean install -Dmaven.test.skip=true Save the job.
Test Build
Click Build Now and monitor the console output to ensure the JAR is produced.
If the first build fails to download dependencies, trigger another build.
Run the Project
Create a Dockerfile in the SpringBoot project root (no file extension):
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"]Update the Jenkins job to add shell steps that rebuild and run the 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:latestSave the job and trigger a build. Verify the container is running with:
docker ps
docker logs zx-orderAccess the application in a browser at http://{SERVER_IP}:8888 to confirm successful deployment.
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.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
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.
