Skip to main content
In this article, we explore the Docker Registry—a central repository where Docker images are stored and managed. Think of Docker images as the foundations for containers; without a registry, there would be no source to pull these essential images. Let’s start by running a simple Nginx container.

Running a Simple Nginx Container

To run the Nginx image, execute the following command:
Here, the image name “nginx” represents the repository name. In Docker’s terminology, when using default settings, “nginx” is shorthand for “library/nginx.” The “library” prefix indicates that this is an official image available on Docker Hub. For example, the fully qualified image reference is:
When no username or organization is specified, Docker assumes the image is stored in Docker Hub. If you create your own images on Docker Hub or within an organization, your username or organization name will be prefixed to the image name. By default, Docker uses Docker Hub (docker.io) for pulling images. Anytime an image is pushed or updated, it is stored in the registry and later pulled for deployments. Beyond Docker Hub, several other registries are popular. For instance, Google manages a registry at GCR.io, which hosts many Kubernetes-related images, particularly for cluster end-to-end tests. These registries offer publicly accessible images that anyone can download. For in-house applications that need restricted access, hosting a private Docker registry is ideal. Cloud providers such as AWS, Azure, and GCP often offer private registry services with your account, allowing you to keep a repository private—a setting that requires valid credentials.

Working with Private Registries

To run a container using an image from a private registry, you must first log in using the Docker login command. For example:
After logging in, run the container by specifying the private registry in the image name:
Ensure you log in before pulling or pushing images from a private registry. Failing to do so may result in errors indicating that the image cannot be found.
For instance, a cloud provider might require a login as follows:
Then, run an internal application from your private registry using:

Setting Up a Custom On-Premises Docker Registry

If you’re running your applications on-premises and lack a pre-configured private registry, you can deploy your own Docker registry. The Docker registry itself is distributed as a Docker image named “registry” which exposes its API on port 5000. To start your custom registry, run:
Once your registry is running, tag your image to include the registry URL. For instance, if your image is named “my-image” and your registry is hosting on the same machine, execute:
Push the tagged image to your local private registry:
This image can then be pulled from any host within your network using either “localhost” (if on the same machine) or the appropriate IP address or domain name:

Conclusion

This article covered the essential aspects of the Docker Registry—from understanding the default behavior on Docker Hub to setting up and managing a private registry, whether hosted on a cloud provider or deployed on-premises. Experiment with these examples in your environment to deepen your understanding of managing and securing Docker images.

Watch Video

Practice Lab