The above is not intended for general purpose production use. It is the quickest, dirtiest way to get a Spring Boot app into a container. See this guide for more detail.
Choosing A JDK
JDK 8u192 introduced support for containers
The JDK will be able to see the memory and CPUs available to the container as opposed to what the host has available
Building A Container
To build a container for our app we need to run docker build
$ docker build -t my-dockerfile-k8s-demo ./
Running docker images will allow you to see the built container
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-dockerfile-k8s-demo latest ab449be57b9d 5 minutes ago 124MB
–>
Jib It!
Jib is a tool from by Google to make building Docker containers easier
Runs as a Maven or Gradle plugin
Does not require a Docker deamon
Implements many Docker best practices automatically
Once logged in you will see two projects, one called library and the other with the same name as your user, we will use the one with the same name as your user
Modify Jib Plugin Configuration
Back in your POM file, modify the Jib plugin, specifically the image name
We also add an execution goal in order to do the container build and push whenever we run our Maven build
Be sure to replace USERNAME in the image name with your supplied user name