Deploying Spring Boot Microservice to Docker
Docker Tutorial - Table Of Contents
Docker Deploying Spring Based WAR Application to Docker Deploying Spring Based JAR Application to Docker Deploying Multiple Spring Boot Microservices using Docker Networking Deploying Multiple Spring Boot Microservices using Docker Compose Deploying Spring Boot + MYSQL Application to Docker Publishing Docker Image to DockerHub Deploy Docker Swarm services using Play With Docker Deploy Docker Swarm services using Docker Stack Deploy Docker Swarm services to multiple AWS EC2 instances Docker Cheat Sheet
Video
This tutorial is explained in the below Youtube Video.- Create a Spring Boot Web Application.
- Create image for starting this application.
- Run the above image as container to start the jar.
Unlike previous tutorial where we used external tomcat,we will be using embedded tomcat for running this application. The project we will as follows-
Run maven command - clean install, and a jar file gets created in the target folder. Next we will start docker and deploy this jar using docker.
Create the dockerfile. Docker file is a list of commands that we want the docker engine to execute. Go to the spring boot project folder and create a docker file as follows-
From openjdk:8 copy ./target/employee-producer-0.0.1-SNAPSHOT.jar employee-producer-0.0.1-SNAPSHOT.jar CMD ["java","-jar","employee-producer-0.0.1-SNAPSHOT.jar"]
Open the terminal and start the docker
systemctl start docker
Now open the terminal and go to the Spring Boot project folder.
Next we will build an image with the name producer.
docker image build -t employee-producer .
Next we will run the above image as a container. Also we will be publishing the docker port 8080 to centos port 8080.