Publishing Docker Image to DockerHubIn this tutorial we will be pushing docker image to dockerhub. Docker Hub is the world's largest library and community for container images. Using Docker Hub we can upload the images we need to share. These can then be downloaded as needed.
Docker Tutorial - Table Of ContentsDocker Deploying Spring Based WAR Application to Docker Deploying Spring Based JAR Application to Docker Deploying Multiple Spring Boot Microservices using Docker Networking Deploying Multiple Spring Boot Microservices using Docker Compose Deploying Spring Boot + MYSQL Application to Docker Publishing Docker Image to DockerHub Deploy Docker Swarm services using Play With Docker Deploy Docker Swarm services using Docker Stack Deploy Docker Swarm services to multiple AWS EC2 instances Docker Cheat Sheet
VideoThis tutorial is explained in the below Youtube Video.
Lets Begin-In previous tutorials we have developed a spring boot microservice which exposes API to get Employee information. We also created the docker image for the employee-producer. In this tutorial we will be creating a Docker Hub account and pushing the image to the Docker Hub
Go to Docker Hub Website
If you do not have an account create a new one by clicking on Sign up for Docker Hub
Once account is created sign in to the docker hub account. We will not see any images in our account.
Previously we have created an image named employee-producer.
We will be pushing this image to Docker Hub.
Using following command we can list the images present-
docker image ls
Using the terminal login to the docker hub account. It will ask for the dockerhub username and password.
Next we will push the image named employee-producer to docker hub using the following command.
docker image push employee-producerBut we get the following exception
This is because only official docker images can be in the above format with only the name
All other docker images should be in the format -
owner/docker-image-name So for this we will need to add the owner tag to the existing image that we want to push to docker hub.
docker image tag employee-producer javainuse/employee-producer
If we now list the docker images we see two docker images with same id.
docker image ls
Now we can push the image to docker hub as below-
docker image push javainuse/employee-producer
If we go to our DockerHub home page we can see that the image has been uploaded to DockerHub.
Download Source CodeDownload it - Employee Consumer Docker Module
Download it - Employee Producer Docker Module