Docker Introduction, Installation on CentOS, and Deploying a Spring Boot Application
This tutorial introduces Docker, walks through installing it on CentOS, demonstrates pulling a Java image, creating a Spring Boot project with Docker Maven plugin, building and running the container, and shows how to view container and Log4j2 logs.
Docker is an open‑source container engine that packages applications and their dependencies into portable images.
The article explains how to install Docker on CentOS (updating the repository, adding the Docker repo, installing the docker‑ce package, and managing the service with systemctl commands such as start, restart, stop, enable, and status).
It shows how to pull a Java 8 image using docker pull java:8 and verify the image list with docker images.
A Spring Boot project is created, the Spotify Docker Maven plugin is added to pom.xml, and a Dockerfile is written to copy the built JAR and run it with Java.
The project is packaged into a Docker image with mvn clean package docker:build, then run using
docker run --name springboot-docker -p 9999:9999 -d <image‑id>. Container status is checked with docker ps, and logs are viewed via docker logs -f --tail=100 <container‑id>. The test endpoint can be accessed at http://<host>:9999/test.
To inspect Log4j2 file logs, the article demonstrates entering the container with docker exec -it <container‑id> /bin/bash, navigating to the log directory, and tailing info.log to see file‑based logs.
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.
Java Captain
Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.
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.
