January 2018
Intermediate to advanced
414 pages
10h 29m
English
In order to create a Docker with our microservice, we first need to package it into a JAR. So let's use Maven to do it, using the package lifecycle:
mvnw package
With the package created, now we need to modify our Dockerfile to actually use it:
FROM openjdk:8-jdk-alpineADD target/*.jar microservice.jarENTRYPOINT ["java","-jar", "microservice.jar"]
We use the ADD command to include our microservice JAR from the target folder. We get it from our target directory, and we add it to the Docker as microservices.jar. Then, we change our entry point to actually execute our JAR.
Now we can build our image again, repeating the build command:
docker build . -t chapter07
This should now give the following output:
Sending build ...
Read now
Unlock full access