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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.