O'Reilly logo

Docker and Kubernetes for Java Developers by Jaroslaw Krochmalski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building the image

To build the Docker image with our Spring Boot artifact, run this command:

$ mvn clean package docker:build

The clean tells Maven to delete the target directory. Maven will always compile your classes with the package command. It is very important to run the package command with the docker:build command. You'll encounter errors if you try to run these in two separate steps. While the Docker image is building, you will see the following output in the console:

The ID of a new image will be presented in the console output. If you wonder how the automatically generated Dockerfile looks the same as, you will find it in the

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required