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.
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 updateyum remove docker docker-common docker-selinux docker-engineyum install -y yum-utils device-mapper-persistent-data lvm2yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repoyum install docker-cesystemctl start dockersystemctl enable dockerdocker version2. 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/blueoceanAccess Jenkins at http://{SERVER_IP}:8080, then unlock it by retrieving the initial admin password:
docker exec -it {JENKINS_CONTAINER} bashcat /var/lib/jenkins/secrets/initialAdminPasswordInstall 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-apidocker stop zx-order || truedocker rm zx-order || truedocker rmi zx-order || truedocker build -t zx-order .docker run -d -p 8888:8888 --name zx-order zx-order:latestAfter 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.
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.
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.
