Dockerize any Spring Boot Microservice in minutes

Published: 03 May 2023
on channel: Fast and Simple Development
2,374
42

Learn how to create a Dockerfile and create a Docker Image for your Spring Boot Application in minutes.

If you can program in Java, you can use Docker.

Follow these Fast and Simple instructions today.

Build your Project with Maven

mvn clean compile package -DskipTests


Create a Docker file

DockerfileFROM openjdk:8-jdk-alpineWORKDIR /optENV PORT 8181EXPOSE 8181COPY target/*.jar /opt/app.jarENTRYPOINT exec java $JAVA_OPT -jar app.jar

Build a Docker image from your jar file

docker build -t thomasjayconsulting/dockerme:0.0.1 .

Run your image in your Docker container

docker run -d -p 8181:8181 --name test_service thomasjayconsulting/dockerme:0.0.1

More can be found on my Udemy classes: https://www.udemy.com/user/tomjay2

Find this and more on my GitHub: https://github.com/ThomasJay

As well as my Web site: https://www.thomasjayconsulting.com

I want to help you learn and find an Amazing Job or just increase your Skills.

#java #docker #springboot