One-Click Jenkins + Docker + Spring Boot Deployment: Step-by-Step Guide
This guide walks through setting up a one‑click automated deployment pipeline for a Spring Boot application using Docker and Jenkins on CentOS 7, covering Docker installation, Jenkins container setup, required plugins, job configuration, building, testing, and running the project.
This article provides a complete, beginner‑friendly tutorial for creating a one‑click automated deployment pipeline that combines Jenkins, Docker, and a Spring Boot project.
1. Install Docker
1. Ensure yum is up to date
yum update2. Remove old Docker versions (if any)
yum remove docker docker-common docker-selinux docker-engine3. Install required utilities
yum install -y yum-utils device-mapper-persistent-data lvm24. Add Docker repository
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo5. Install Docker CE
yum install docker-ce6. Start Docker and enable on boot
systemctl start docker
systemctl enable docker7. Verify installation
docker version2. Install Jenkins
Run Jenkins inside a Docker container (make sure port 8080 is free):
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/blueoceanAfter a few minutes, access Jenkins at http://{server_ip}:8080.
2.1 Unlock Jenkins
# Enter the container
docker exec -it {Jenkins_container_name} bash
# View the initial admin password
cat /var/lib/jenkins/secrets/initialAdminPassword2.2 Install recommended plugins
Select “Install recommended plugins” during the setup wizard.
2.3 Create admin user
Remember the administrator credentials you create.
3. System configuration
Install the following plugins (via Manage Jenkins → Manage Plugins):
Maven Integration
Publish Over SSH (optional)
Gitee (if using Gitee, Git is built‑in)
Configure Maven under “Manage Jenkins → Global Tool Configuration”.
4. Create a Jenkins job
4.1 New job
Create a “Freestyle project” and give it a name.
4.2 Source code management
Select Git, enter the repository URL, add credentials, and save.
4.3 Build trigger
Add a build step “Invoke top‑level Maven targets” with the goal:
clean install -Dmaven.test.skip=true4.4 Save
Save the job configuration.
5. Test the pipeline
5.1 Build
Click “Build Now” and monitor the console output.
5.2 Verify artifact
After a successful build, the generated JAR appears in the workspace.
6. Run the project
6.1 Dockerfile
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"]6.2 Jenkins job steps for building the image and running 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:latestCheck the container with docker ps and view logs via docker logs. Access the application at http://{server_ip}:8888.
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.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
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.
