Publishing an Docker Image to Docker Hub

In previous blog, I have explained how to create custom Image . In this blog will explain how to publish an Image to Docker Hub.

Publishing an Docker Image to Docker Hub

Prerequisites

  • Docker

Create a Docker Hub account

Before we pushing an Image to Docker Hub . We need to create an account in Docker Hub. The sign-up process is simple and available on the front page of Docker Hub

Creating repositories

1. To create a repository , sign into Docker Hub , click on Create Repository button

2.png

2. Add repository name and click on create button. Description is optional and also we can choose visibility of repository .

1.png

Pushing a Docker container image to Docker Hub

1. To push an image to Docker Hub, you must first name your local image using your Docker Hub username and the repository name that you created through Docker Hub on the web.

We can add multiple images to a repository by adding a specific : to them (for example docs/base:testing). If it’s not specified, the tag defaults to latest.

Syntax: docker build -t <hub-user>/<repo-name>[:<tag>]

build-image.png

2. Now we can check image created or not using docker images command . Docker image command gives list of images recently created.

Syntax: docker images

list-image.png

3. To push an image to docker hub , we need to login to the docker hub using docker login command. It will ask for username and password , enter username and password and successfully login .

Syntax: docker login

d-l.PNG

4. Now we can push this repository to the registry designated by its name or tag.

Syntax : docker push <hub-user>/<repo-name>:<tag>

push-s.png

Conclusion

In this blog, we learn about how to create Docker Hub account , how to create repository in Docker hub , building Docker images for our usernames. We then pushed those Docker images to our Docker Hub repository .