Docker – Push a container to the Private/Public DockerHub Registry

Push a container to DockerHub Registry

Today in this article, we will see the step-by-step process to Push a container to DockerHub.

Updated October 2026: a personal access token login section, a fix for the ‘denied’ push error, and an FAQ.

We will log in to the docker account, then create a TAG for the Target image using the source, and then push the container to docker in the specified repository.

Today in this article, we will cover below aspects,

Getting started

Log in to the Docker account

While pushing an image or a repository to a docker remote registry, you must log in to the docker account using CLI, etc else you might see an error that access to the resource is denied.

Command

docker login

Log in with a personal access token instead of a password

Use a personal access token (PAT) to sign in before you push, not your account password. You must be signed in through Docker Desktop or the CLI, and a token is safer on shared machines and CI because you can limit it, give it an expiry date and revoke it without touching your password.

In plain English: A personal access token is like a hotel key card. It opens only the doors it was coded for, it expires, and the front desk can cancel it without changing the locks on your house.

How do you create a Docker Hub access token?

Create the token in your Docker account settings. These steps show the order:

  1. Open the page: In Docker Home, go to Account Settings, then Personal access tokens.
  2. Add a description: Name the machine or job that will use it, so you know what to revoke later.
  3. Set an expiry date: Pick a date that matches how long you need the token.
  4. Choose the access level: Pushing needs more than Read access. A read-only token logs in fine, then fails on docker push.
  5. Copy it immediately: Docker doesn’t show the token again. It starts with dckr_pat_.

How do you pass the token to docker login?

Send the token on stdin with the --password-stdin flag and use it in place of the password. Don’t use -p, because the secret ends up in your shell history.

In GitHub Actions, use docker/login-action@v3. It takes your username and token from repository secrets, so nothing sensitive sits in the workflow file.

What if login succeeds but the push fails?

Check the credsStore entry in ~/.docker/config.json. A broken credential helper can make the login look fine while the push still ends in a “denied” error.

Fix or remove that entry, then log in again. If the error persists, confirm the token’s access level allows writes and that the image is tagged under a namespace you own.

Create a target TAG that refers to the Source TAG

In this step, we will create a target TAG that refers to the Source TAG.

Let’s first check the available images in your local and then tag them appropriately.

Below I have an image called “thecodebuzzapp” with TAG as “latest“. This image I would like to push to docker hub.

Create a target TAG that refers to the Source TAG

We have learned the basics of how to create a docker container with examples in our previous examples.

Let’s use the below command to tag our target image with the source tag as below

Command

docker tag local-image:tagname new-repo:tagname

Where,

  • local-image – Is the name or Id of the local image. In the above example “thecodebuzzapp” is the image name.

  • tagname – TAG name used for the local image. In the above example “latest” is the TAG name.

  • new-repo – This is the target/remote repository name where you would like to push the docker local image

  • tagname – TAG name used for target/remote image

Example

docker tag thecodebuzzapp:latest firstthecodebuzz/myfirstapp:coolapp

Push a container to DockerHub Registry

If the repository doesn’t exist yet, the push will create it automatically under your namespace. You can still create it first on Docker Hub if you want to choose public or private visibility and add a description,

Push the Image/Container to the remote Docker Hub Repository

Push the Image/Container to the remote Docker Hub Repository

Let’s now push the image to the docker repository using the below command,

Command


docker push new-repo:tagname

Example

docker push firstthecodebuzz/myfirstapp:coolapp

Push the Image/Container to the remote Docker Hub Repository

Finally, you shall see your docker image successfully pushed,

Push a container to DockerHub Registry

References:

  • Docker- Containerize an Angular App with NGNIX
  • Build App in a Docker Container-Getting Started
  • Do you have any comments or ideas or any better suggestions to share?

    Please sound off your comments below.

    Happy Coding !!



    Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published (2026) best practices and guidelines for software design and development.



    Frequently asked questions

    Do I need to create the repository on Docker Hub before pushing?

    No. If the repository doesn’t exist, the push creates it automatically, as long as the image name uses your namespace, for example your-username/myfirstapp:coolapp. Creating it first in the Docker Hub UI is optional, but it’s useful when you want to make it private or add a description before the first push. The step in this article that says to create the repository first is a convenience, not a requirement.

    How many private repositories does a free Docker Hub account get?

    A Personal (free) account gets unlimited public repositories and up to one private repository. Paid plans raise the private limit. If you go over it, pushes can fail, and one community thread reports a stuck state that was only cleared by deleting the over-limit repository and pushing again.

    Should I log in to Docker Hub with a password or a personal access token?

    Use a personal access token, especially in CI. Pass it with --password-stdin so it stays out of your shell history. The token needs more than Read access to push. You can also set an expiry and revoke a token at any time without changing your account password.

    Do Docker Hub pull rate limits affect docker push?

    No, the limits apply to pulls, not pushes. Authenticated Personal accounts get 200 pulls per 6 hours, and unauthenticated users get 100 per IPv4 address or IPv6 /64 subnet. Logging in moves the quota from your IP address to your account, which helps CI jobs that pull base images before they build and push.

    Leave a Reply

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