Building Docker images with Maven

There are various Docker Maven plugins that can be used:

You can use any of these. I found the Docker Maven plugin by @rhuss to be best suited for us. It has not been updated for a while, but it works perfectly.

We need to introduce the Docker Spring profile in application.yml before we start discussing the configuration of docker-maven-plugin. It will make our job easier when building services for various platforms.

Configuring the Spring profile for Docker:

  1. We'll use the Spring profile identified as Docker.
  2. There won't be any conflict of ports among embedded Tomcat, ...

Get Mastering Microservices with Java - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.