Docker container registries like the Docker Hub are platforms for hosting and sharing Docker containers. While the default Docker Hub is focused on public containers, most cloud providers like AWS and GCP will run their own private container registries.
What Are Docker Registries?
Container registries are an online storage and distribution system for named Docker images. It’s pretty similar to a package manager like NPM, since it can store different versions of images as well. Anyone with an registry account can login and upload built images by running docker push
with a username/imagename
parameter:
docker push anthonyheddings/testcontainer
Then, if you wanted to use that container somewhere else, you can download it in the same way:
docker pull anthonyheddings/testcontainer
Unless you’re building your image FROM scratch
, you’re probably pulling from the Docker Hub. The Docker Hub is the default Docker registry.
When you write a Dockerfile for your application, you can extend images from the Docker Hub using the FROM
command:
FROM ubuntu
For some containers like ubuntu
, they’re Docker Official Images, which means they’re so widely used that you don’t need to specify the username that uploaded it (which can be redundant if you’re just typing ubuntu/ubuntu
).
Tagging Containers
Containers in Docker registries are organized into Repositories. They’re pretty similar to the concept of Git repositories, except instead of branches, containers are organized using different tags.
Tags are simply labels that provide a better way to manage version control and releases. You can assign them to any completed build. Rather than referencing the build ID, you can tag an image with a label in the major.minor.patch format and easily be able to tell which image is which, or whatever format your organization prefers.
If you don’t specify a tag, Docker will automatically apply the “latest” tag. Whenever you pull an image from the Hub, you’re likely pulling latest
unless you specify a version number.
You can use docker tag
to manually tag images, but it’s much easier to use -t
with docker build
.
docker build -t username/image:tag .
When you push the image to the Docker Hub, or any other registry, you’ll be able to pull down different versions depending on their tag.
Alternatives to Docker Hub
The Docker Hub is the default, so if you don’t specify a different one, all Docker commands that work with registries will append hub.docker.com as the default.
However, many cloud providers will offer their own Docker registries as a service, which usually integrate with the other container related services they provide. For example, there’s Google Container Registry, which works well with Cloud Run and their Kubernetes service.
You can switch to a new registry, you simply prepend the registry URL to all container references. For GCR, that would be gcr.io
:
gcr.io/anthonyheddings/test
Much like Docker Hub, you will need to login to the registry with docker login.
AWS has Elastic Container Registry, which works well with Elastic Container Service and Elastic Kubernetes Service.
Azure has the Azure Container Registry, which works with their Kubernetes service.
- › How to Know If Someone Restricted You on Instagram
- › You Can Wash Your Motherboard In a Dishwasher (But You Probably Shouldn’t)
- › Bing Chat AI Now Has Better Search and Higher Limits
- › Fix: “Message Has Not Been Downloaded From the Server” on iPhone
- › How to Enable Dark Mode in Real Life
- › ChatGPT Network Error: 7 Fixes to Try