Member-only story

Build and Push to Docker With Maven

Automatically push your project to Docker using Spotify, fabric8, and JIB Maven plugins

Nassos Michas
Better Programming
7 min readOct 7, 2019

--

Your build is now fully automated with Maven. All your plugins and dependencies are in place. Your JAR is waiting for you in target.

But how do you turn this into a Docker image and push it to your preferred Docker registry? Let’s do it together next.

Let There Be pom

We’ll create and build a simple Hello World command-line app using the Maven Quickstart Archetype:
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DgroupId=com.test -DartifactId=maven-docker -Dversion=1.0.0-SNAPSHOT

Quick Hello World archetype

Before we check if the auto-generated project compiles and runs, we need to modify the pom.xml to build an executable JAR by modifying the plugins section adding the following plugin:

--

--

Nassos Michas
Nassos Michas

Written by Nassos Michas

BSc, MSc in Software engineering | Cert. Scrum master | Cert. Professional for Software Architecture | Cert. Professional for Requirements Engineering

Responses (1)

What are your thoughts?