If you want to get a Spring Boot app running in Docker fast and stop pretending manual deployment is a rite of passage, you are in the right place. This guide walks you from build artifact to running container with the minimum amount of ceremony and the maximum amount of practical commands.
A runnable jar produced by Maven or Gradle, a tiny Dockerfile that actually does the job, a local image you can run for testing, and optional steps to push the image to a registry for real world deployment. Think of this as containerization for people who like short checklists and bad coffee.
Use your project build tool to produce an executable jar. If you use Maven run
mvn clean package
If you use Gradle run
./gradlew bootJar
The jar will usually appear in target
for Maven or build/libs
for Gradle. That jar is your app wrapped and ready for a tiny VM we call a container.
Keep it small and boring. Pick a compact Java runtime image, copy the jar in, and set the launch command. No multi stage drama required for a quick test.
FROM eclipse-temurin:17-jdk-slim
COPY target/myapp.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
Notes and swaps
build/libs
.From the project root run a straightforward build and tag it for local testing.
docker build -t myapp .
Tip If you plan to push to a registry later add a meaningful tag and consider using your registry naming convention in the tag.
Start the container in the background and publish a port so you can hit the app from your machine.
docker run -d --name myapp_container -p 8080:8080 myapp
Check logs with docker logs -f myapp_container
or hit the endpoint with curl or a browser at http://localhost:8080
. If the app does not start check the jar path and Java version.
Run your smoke tests locally. Use curl or an API client to validate the endpoints. When you are happy push the image to a registry using your preferred workflow and tag style. Common registry commands look like logging in and pushing an appropriately named image.
java -jar
.-p hostPort:containerPort
.That is it. From a successful jar build to a local Docker container in a few commands. This process gives you repeatable local testing and a solid foundation for CI pipelines and production containerization without unnecessary drama.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.