How to push docker image to docker hub using git bash

In this quick post, we will see how to push docker image to docker hub using git bash. If you are facing some issue like denied: requested access to the resource is denied or may be some different issue, this post might help you.

1. Register and log in to the docker hub using the below API.

https://hub.docker.com/

2. Once logged in create an access token.

steps to create an access token – click on username(i.e right corner) ->> account settings ->> security->> new access token

Copy the token and save it somewhere since it will be gone once you close it.

3. Open git bash or cmd and run the below command

docker login -u yourusername -p accesstokenthatwecopied

You should able to see the message – Login Succeeded

4. Create a Docker hub repository

5. Click on Create

6. Prepare command using docker hub repository name

docker tag youimagename username/first-repo:justatagname

Note- At last just give some tag name. It could be anything.

for example – docker tag docker-second2 deepak/first-repo:justatagname

7. Push image file to docker hub using below command

docker push username/first-repo:justatagname

That’s all about How to push docker image to docker hub using git bash