How To Push Docker Images To Docker Hub Repository Using Docker Maven plugin - Little Big Extra Skip to main content

How To Push Docker Images To Docker Hub Repository Using Docker Maven plugin

Push a Docker image to DockerHub using docker maven plugin fabric8.io

 

Introduction

If you want to push a docker image to Docker Hub repository, it can be achieved using docker maven plugin from fabric8.io. This plugin lets you build images, start and stop containers and push it to Docker repositories

In case you are wondering the difference between a container and image, please note that in docker terminology a running image is called container.
In this tutorial, we are going to

  • Build a docker image
  • Push image to Docker Hub repository

&nsbp;

Want to build a docker image first using this plugin ?
Read Here : How to Build a Docker Image and start stop container
  1. For the below example, I have used Spring Boot Rest service project which is connected to MongoDB. See below link for reference.
  2. Using io.fabric8 plugin, under the plugin section add the io.fabric8 plugin

  3. We need to first build the image from Dockerfile, this plugin supports all the command which are in Dockerfile and you can directly create a docker image by giving arguments in pom.xml but In my view making docker images from Docker file is much easier and simpler. So we will ask maven plugin in below step to look for Dockerfile in root( project base directory)
  4. Next we specify the docker registry address
  5. Now we need to add authentication credentials in <authconfig> tag
  6. We will add execution phases, where we will push the image
  7. Now run the pom.xml using mvn clean install and check your docker hub repo after some time to see if image has been pushed. If you are pushing the image for first time its gonna take some time  depending on the size of image.

Here is the complete build section from the plugin, hope this help.

 

 

If you get an error : io.fabric8:docker-maven-plugin:0.20.0:build failed: A tar file cannot include itself

How to fix- A tar file cannot include itself

Related Posts

2 thoughts to “How To Push Docker Images To Docker Hub Repository Using Docker Maven plugin”

  1. Request you to include entire pom.xml so that it will be usefull to find the tags which are included in correct order.

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami