Lesson 1: The Warehouse (Docker Registry)
You've built an image on your laptop. How do you get it to the production server? You push it to a registry — a warehouse for Docker images.
What is a Registry?
A Docker registry is a service that stores and distributes Docker images. Think of it like GitHub, but for containers instead of code.
Popular Registries
| Registry | URL | Type | |----------|-----|------| | Docker Hub | hub.docker.com | Public/Private | | GitHub Container Registry | ghcr.io | Public/Private | | AWS ECR | aws.amazon.com/ecr | Private | | Google Artifact Registry | cloud.google.com | Private | | Azure Container Registry | azure.microsoft.com | Private |
The Push/Pull Workflow
Developer Laptop Registry Production Server
┌──────────┐ push → ┌──────────┐ ← pull ┌──────────┐
│ Build │ ─────────→ │ Store │ ←───────── │ Deploy │
│ Image │ │ Image │ │ Image │
└──────────┘ └──────────┘ └──────────┘
Logging In
docker login # Docker Hub
docker login ghcr.io # GitHub
docker login 123456789.dkr.ecr.us-east-1.amazonaws.com # AWS ECR
Tagging Images
Before pushing, you must tag your image with the registry path:
# Format: registry/repository:tag
docker tag my-app:v1 cloudcorp/my-app:v1
docker tag my-app:v1 ghcr.io/cloudcorp/my-app:v1
Pushing Images
docker push cloudcorp/my-app:v1
Docker uploads each layer individually. Layers that already exist in the registry are skipped (deduplication).
Pulling Images
docker pull cloudcorp/my-app:v1
docker pull cloudcorp/my-app:latest
Searching Docker Hub
docker search nginx
NAME DESCRIPTION STARS OFFICIAL
nginx Official Nginx image 18000 [OK]
jwilder/nginx Automated nginx reverse proxy 2100
Look for the OFFICIAL badge — these are maintained by the software authors.
Image Tagging Strategy
| Tag | Purpose | Example |
|-----|---------|---------|
| latest | Most recent build | my-app:latest |
| Semantic version | Specific release | my-app:2.1.0 |
| Git SHA | Exact commit | my-app:a1b2c3d |
| Date | Build timestamp | my-app:2025-05-19 |
| Environment | Target deployment | my-app:staging |
Best practice: Use specific versions in production, never latest.
Mission Objective
Work with the registry:
- Search: Run
docker search nginxto browse available images. - Tag: Tag your image with
docker tag my-app:v1 cloudcorp/my-app:v1. - Inspect layers: Run
docker history nginxto see how an image was built.