DEV Community

Matthew Dailey
Matthew Dailey

Posted on

Adding Docker image to Docker Hub private repository

I've learned something as straightforward as adding a Docker image to a repository can be somewhat frustrating. When I say private repository I mean a private repository hosted on Docker Hub.

Here are the steps I had to take to successfully push a Docker image:

  1. If you recently created a private repo, log out of Docker and then login back in by running docker logout and docker login commands. The reason behind this is to make sure Docker is aware that the private repo exists.
  2. This is very important. The Docker image has to be named exactly the same as the private repo. If it is not named the same, you will get a requested access to the resource is denied error. To change the Docker image name, run 'docker tag [current image name] [dockerhub username/private repo name:tag]. You can add whatever you want for the tag, I added '1.0'.
  3. Now with the Docker image having the correct name, you can add it to the private repository. Run docker push [username/private repo name:tag]. For example docker push johnsmith/demorepo:1.0.

You're done.

Latest comments (0)