This is a Maven plugin helps Maven integrate with Docker.

  • Make the Docker build process integrate with the Maven build process. If you bind the default phases, when you type mvn package, you get a Docker image. When you type mvn deploy, your image gets pushed.
  • You can type mvn dockerfile:build and later mvn dockerfile:tagand later mvn dockerfile:push without problems. This also eliminates the need for something like mvn dockerfile:build -DalsoPush; instead you can just say mvn dockerfile:build dockerfile:push.
  • This is useful when you want to run integration tests involving multiple services.

This configures the actual plugin to build your image with mvn package and push it with mvn deploy. Of course you can also say mvn dockerfile:build explicitly.

            <!-- replace `mydockerreddah` with your docker id-->

A corresponding Dockerfile could look like:

FROM openjdk:8-jre
MAINTAINER Reddah Cherara <>

ENTRYPOINT ["/usr/bin/java", "-jar", "/usr/share/myservice/myservice.jar"]

# Add Maven dependencies (not shaded into the artifact; Docker-cached)
ADD target/lib           /usr/share/myservice/lib
# Add the service itself
ADD target/${JAR_FILE} /usr/share/myservice/myservice.jar

You no longer have to say something like:

mvn package
mvn dockerfile:build
mvn verify
mvn dockerfile:push
mvn deploy

Instead, it is simply enough to say:

mvn deploy

With the basic configuration, this will make sure that the image is built and pushed at the correct times.

You have to created a serverId in your ~/.m2/settings.xml file?
Like here:


You then need to refer to it in your pom.xml (serverId).

For the Encryption of your Docker Hub Password use this link :  

Generate a temporary BCrypt hash (Find a generator online. I used this one: Or

If you want to encrypt that password, please follow this mini guide -->

curl -s -L

Depend on Docker images of other services :

You can depend on the Docker information of another project, because this plugin attaches project metadata when it builds Docker images. Simply add this information to any project:


Now, you can read information about the Docker image of the project that you depended on:

String imageName = getResource("META-INF/docker/com.spotify/foobar/image-name");

This is great for an integration test where you want the latest version of another project's Docker image.

Note that you have to register a Maven extension in your POM (or a parent POM) in order for the docker-info type to be supported:


Or Use other Docker tools that rely on Dockerfiles with Fig or docker-compose or some other system that works with Dockerfiles. For example, a docker-compose.yml