How to push Image to Docker Registry

Pushing Docker image to Dockerhub

If you want to push a docker image to dockerhub, then you need to have your image ready in your local docker workstation.

Before we push an image to dockerhub, we need to do follow few steps:

Dockerhub Account:

Before pushing any image to dockerhub, you will need a dockerhub account. Please visit Dockerhub and create your account.

Login to Dockerhub:

You will need to login to dockerhub from your local work station. run the following command.

docker login

It will ask you for your docker username and password, for successful authentication, we will get following output.

docker login

Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: docker_username
Password: enter_your_password
Login Succeeded

Tag Docker Image:

Tagging a docker image means, giving your docker image a name. You will need to give image name as user_name/image_name

Syntax: docker tag image_name user_name/image_name

docker tag nginx:latest username/nginx:latest

This command will create a image with name user_name/nginx:latest from nginx:latest.

Push Docker Image:

Now we will push the image to dockerhub.

Syntax: docker push username/image_name

docker push username/nginx:latest

This command will push your docker image to dockerhub.

1 Like

Can you please tell me how to create my docket registry ?