Assuming we have prepared a valid Dockerfile for each service, the next step is to build the whole Maven project with the mvn clean install command, before building a Docker image for every service.
When building a Docker image, you should always be in the root directory of every microservice source code. The first container that has to be run in our microservices-based system is a discovery server. Its Docker image has been named piomin/discovery-service. Before running Docker's build command, go to the module discovery-service. This Dockerfile is a little simpler than other microservices, because there is no environment variables to set inside the container, shown as follows:
FROM openjdk:8u151-jdk-slim-stretch ...