DEV Community

Cover image for Dockerhub and Registry Server
Igor Souto
Igor Souto

Posted on

Dockerhub and Registry Server

Dockerhub is the Docker's website for repositories of images, very similar to Github, where we create repositories of code, that other people can use. On Docker, we host our Docker images, private ou public, of enterprises or not. And then, other people can use that image that you've created.

Accessing the Dockerhub's website, we can create our account and start using it.

Some commands


With the command docker login, you can sign in your Dockerhub's account. If you want to sign in another Registry instead of Dockerhub, just put the URL after like docker login <URL> .


With the command docker push, it's possible to push a local image to Dockerhub.

The image's name must contain:

Your Dockerhub's username + the name that you want to give for the image + the version:

docker push username/webserver:1.0
Enter fullscreen mode Exit fullscreen mode

To change the docker's name, use the command:

docker tag username/serverweb:2.0
Enter fullscreen mode Exit fullscreen mode


To download the image from Dockerhub to the local machine, use:

docker pull image-name
Enter fullscreen mode Exit fullscreen mode

The download will be made, and when finish, run using like:

docker run -ti webserver
Enter fullscreen mode Exit fullscreen mode


A registry is like a "personal Dockerhub", for you or for your company. You can run in your local machine or any server, setting your own DNS, access control for users and etc.

It's possible to add web interfaces, so you can easily view your registry, in Dockerhub has many examples of templates to install.

Creating a local registry

For building your local registry, in order not to need Dockerhub, either for your self or your company, we do the following:

docker run -d -p 5000:5000 --restart=always --name registry registry:2
Enter fullscreen mode Exit fullscreen mode

This command is linking our port 5000 of host docker (local machine) and the image.

We are telling Docker that if something happens to our container and he dies, it will be automatically restarted. We're giving our container the name "registry" and using the image "registry:2" from Dockerhub.

Pushing an image to the local registry

For pushing images to the local registry, just renaming an image, replacing the username for the registry's URL, that in our case it would be like:

 docker tag <image-id> [localhost:5000/webserver:](http://localhost:5000/webserver:1.0`)1.0
Enter fullscreen mode Exit fullscreen mode

But it could be a server DNS etc.

We use docker push for pushing the image, as we did for pushing to Dockerhub, and docker pull if we want to download an image from the registry.

For verifying the images in your registry, run: (if is a DNS you would change it and either the port.

curl localhost:5000/v2/_catalog
Enter fullscreen mode Exit fullscreen mode


Dockerhub is a very interesting alternative if you or a company wants to share images, whether public or private. And for those who want to have a more private alternative, with their own rules and settings, the Registry is a great alternative, being very customizable and having a lot of content available to assist those who want to create one.

Top comments (0)