Image Registries
A registry is a storage service for Docker images.
Introduction
A registry is a storage service for Docker images. Docker Hub is the default public one; companies usually run private registries (GHCR, ECR, GAR, Artifactory) for proprietary code.
Purpose of this lesson
This lesson teaches Image Registries as an engineering decision: what problem it solves, when to use it, how to implement it safely, and what signals tell you it is failing.
Understanding the topic
Use this in day-to-day container operations: pulling images, running processes, inspecting failures, publishing artifacts, and keeping the Docker host clean and predictable.
Core concepts to understand:
docker loginauthenticates; credentials cached in~/.docker/config.json.- Naming:
registry/namespace/name:tag(e.g.ghcr.io/acme/api:1.0). - Default registry is Docker Hub if no host is in the name.
- Registries support webhooks, scanning, immutable tags, retention policies.
Visual explanation
Architecture or command flow to keep in mind:
# Push to GitHub Container Registrydocker login ghcr.io -u USER -p $TOKENdocker tag myapp:1.0 ghcr.io/acme/myapp:1.0docker push ghcr.io/acme/myapp:1.0
Step-by-step explanation
- Run the command or manifest exactly once on a clean Docker host and read the output carefully.
- Inspect the object Docker created: image, container, network, volume, port mapping, process, or registry tag.
- Break one realistic assumption such as a missing port, bad tag, stopped daemon, wrong network, or deleted volume.
- Use
docker ps,logs,inspect,stats, andsystem dfto locate the failure. - Write the final command or configuration into a repeatable script, Compose file, or CI job.
Informative example
Use the example below as a working baseline, then verify the runtime behavior instead of assuming the command or file is correct.
# Push to GitHub Container Registrydocker login ghcr.io -u USER -p $TOKENdocker tag myapp:1.0 ghcr.io/acme/myapp:1.0docker push ghcr.io/acme/myapp:1.0
A production-minded check usually includes docker ps, docker logs, docker inspect, and one validation from outside the container such as curl, a database connection, or a registry pull.
# Verification loop for Image Registriesdocker ps -adocker logs --tail=100 <container-name>docker inspect <container-or-image-name>docker system df
Real-world use
Every cloud has its own registry — AWS ECR, Google Artifact Registry, Azure ACR — usually free for the first few GB and integrated with IAM.
Enterprise use cases
In a mature engineering organization, Image Registries is documented as a repeatable pattern with approved base images, ownership labels, CI checks, security expectations, rollback notes, and troubleshooting commands. The difference between a tutorial and production practice is that every container decision must be observable, reviewable, and reversible.
Best practices
- Use immutable tags in production (push 1.0.1, not overwrite 1.0).
- Set a retention policy so old images don't bloat your bill.
- Store registry creds in a secret manager, not in
config.jsonon CI.
Debugging tips
- Read logs before restarting; a restart often removes the timing context you need for root cause analysis.
- Use
docker inspectto compare configured state with actual runtime state. - Check daemon health, disk usage, image tags, exit code, and port mappings before blaming application code.
Optimization strategies
- Prefer explicit names, labels, tags, and networks so cleanup and debugging stay predictable.
- Pin versions for repeatability, then update intentionally through a scheduled base-image refresh.
- Use
docker system dfand targeted prune commands to control local and CI disk growth.
Advanced interview questions
Interview Prep
Practice concise answers, then expand each card for the explanation.
1QuestionDifference between Docker Hub and a private registry?+
Answer
2QuestionHow is registry authentication handled?+
Answer
3QuestionWhat is an immutable tag?+
Answer
Hands-on exercise
Create a small lab for Image Registries: run the example, inspect the created Docker object, intentionally introduce one mistake, and record the command that reveals the failure. The goal is not just to make the happy path work; it is to build operational reflexes.
# Hands-on lab scaffoldmkdir -p docker-image-registries-labcd docker-image-registries-lab# Add the Dockerfile, compose.yml, or command from this lesson.# Then run one happy-path test and one broken-path test.docker versiondocker infodocker system df
Summary
Image Registries matters because Docker is not only a packaging tool; it is a runtime, build, networking, storage, and delivery workflow. Treat each lesson as a production habit: make it repeatable, inspectable, secure, and easy to debug.