Docker Hub is the main public registry for Docker images. In other words, it’s a service where we can search, download, publish, and share container images.
Up until now, we’ve been using images like nginx, mysql, ubuntu, or node almost as if they appeared by magic. But those images don’t come from nowhere. Docker usually downloads them from Docker Hub, which is the default configured registry.
Docker Hub is not the only registry that exists. There are also alternatives like GitHub Container Registry, GitLab Container Registry, Amazon ECR, Azure Container Registry, or Google Artifact Registry.
But Docker Hub remains the most common starting point, especially when we are learning.
Think of Docker Hub as a kind of “package repository”, but for container images. Just like in programming we use NuGet, npm, PyPI, or Maven Central, in Docker we use a registry to distribute pre-built images.
What is an Image Registry
An image registry is a server that stores Docker images and allows you to download them with docker pull or upload them with docker push.
When we run:
docker pull nginx
Docker looks for the nginx image in the default registry. If we don’t specify otherwise, that registry is Docker Hub.
That’s why we can write commands as simple as:
docker run nginx
And Docker, if it doesn’t have the image locally, automatically does something similar to:
docker pull nginx
docker run nginx
In other words, it first downloads the image and then creates the container from it.
Repositories in Docker Hub
On Docker Hub, images are organized into repositories. A repository groups together the different versions or variants of the same image.
For example, nginx is a repository. mysql is another. python is another.
When an image belongs to a user or organization, it is usually written like this:
user/repository
For example:
luisllamas/my-api
This means that the repository my-api belongs to the user or organization luisllamas.
Searching for Images
The most convenient way to search for images is to go to the Docker Hub website and use the search bar.
You can also search from the terminal with:
docker search mysql
This command shows a list of images related to MySQL, along with a brief description.
Downloading Images
To download an image, we use docker pull:
docker pull nginx
This downloads the image to your machine. From that moment on, Docker can create containers using that image without downloading it again.
Publishing Our Images
Docker Hub is not just for downloading other people’s images. We can also upload our own images.
The basic workflow is:
Create an account on Docker Hub.
Log in from the terminal.
docker login
Build a local image.
docker build -t my-app .
Tag it with a name that points to your user or repository.
docker tag my-app docker-user/my-app:1.0
Upload it with docker push.
docker push docker-user/my-app:1.0
From that point on, another machine could download it with:
docker pull docker-user/my-app:1.0
Before uploading an image, check that you have not included sensitive files inside: .env, private keys, certificates, tokens, .git folders, etc.
A published image can be downloaded and analyzed layer by layer. Do not assume something remains hidden because it “isn’t visible” when the container starts.
