You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
A Docker registry is a storage and distribution system for Docker images. When you run docker pull nginx, Docker downloads the image from a registry. When you build an image on your machine and want to deploy it to a server, you push it to a registry so the server can pull it.
Docker Hub is the default public registry at https://hub.docker.com. It hosts official images for popular software (nginx, postgres, redis, node, python, and thousands more) as well as community and personal images.
Image names on Docker Hub follow the pattern username/repository:tag. Official images (maintained by Docker and upstream vendors) use just repository:tag — for example, nginx:latest or postgres:16.
# Log in to Docker Hub
docker login
# Pull an official image
docker pull postgres:16
# Pull a user image
docker pull myusername/my-app:1.0
# Tag a local image for Docker Hub
docker tag my-app:latest myusername/my-app:1.0
# Push to Docker Hub
docker push myusername/my-app:1.0
# Log out
docker logout
Understanding image references is important when working with multiple registries:
# Tag for multiple registries
docker tag my-app:latest myuser/my-app:1.0
docker tag my-app:latest ghcr.io/myorg/my-app:1.0
# Push to both
docker push myuser/my-app:1.0
docker push ghcr.io/myorg/my-app:1.0
In production you often want a private registry so that your images are not publicly visible. Major cloud providers offer managed registries:
# Log in to Amazon ECR (requires AWS CLI configured)
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789.dkr.ecr.us-east-1.amazonaws.com
# Tag and push to ECR
docker tag my-app:latest 123456789.dkr.ecr.us-east-1.amazonaws.com/my-app:latest
docker push 123456789.dkr.ecr.us-east-1.amazonaws.com/my-app:latest
For development or air-gapped environments you can run Docker's open-source registry image:
# Start a local registry on port 5000
docker run -d -p 5000:5000 --name registry registry:2
# Tag and push to the local registry
docker tag my-app:latest localhost:5000/my-app:latest
docker push localhost:5000/my-app:latest
# Pull from the local registry
docker pull localhost:5000/my-app:latest
A good tagging strategy makes it easy to roll back and track what is deployed:
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.