Writing your Dockerfile
So far in this chapter, we have seen how to package our application and how to install Docker. Now that we have our JAR artifact and Docker set up, let's see how to Dockerize our microservice application using Docker.
Getting ready
In order to Dockerize our application, we will have to tell Docker how our image is going to look like. This is exactly the purpose of a Dockerfile. A Dockerfile has its own syntax (or Dockerfile instructions) and will be used by Docker to create images. Throughout this recipe, we will try to understand some of the most commonly used Dockerfile instructions as we write our Dockerfile for the geolocation tracker microservice.
How to do it...
- First, open your STS IDE and create a new file called
Dockerfile
in the geolocation project. The first line of the Dockerfile is always theFROM
instruction followed by the base image that you would like to create your image from. There are thousands of images on Docker Hub to choose from. In our case...