Registry Basics
What is a Docker Registry?
A Docker registry is a storage and distribution system for Docker images. It allows users to push, pull, and manage container images in a centralized location. Docker Hub is the most well-known public registry, but organizations often use private registries for more control and security.
Key Components of a Docker Registry
Component |
Description |
Purpose |
Image Repository |
Storage location for Docker images |
Organize and store container images |
Authentication |
User access control |
Manage who can push or pull images |
Image Tagging |
Version identification system |
Track different versions of images |
Registry Architecture
graph TD
A[Docker Client] -->|Push/Pull| B[Docker Registry]
B -->|Store Images| C[Image Repository]
B -->|Authenticate| D[Authentication Service]
Setting Up a Local Registry
To set up a basic Docker registry on Ubuntu 22.04, use the following commands:
## Pull the official registry image
docker pull registry:2
## Run a local registry on port 5000
docker run -d -p 5000:5000 --restart=always --name registry registry:2
## Verify the registry is running
docker ps | grep registry
Registry Types
-
Public Registries
- Docker Hub
- Quay.io
- GitHub Container Registry
-
Private Registries
- Self-hosted registries
- Cloud provider registries
- Enterprise container registries
Best Practices
- Use authentication for private registries
- Implement image scanning
- Regularly clean up unused images
- Use image tags for version control
LabEx Tip
When learning Docker registry management, LabEx provides hands-on environments to practice setting up and troubleshooting registries in a safe, controlled setting.
Common Registry Configurations
## Example: Configuring registry with authentication
docker run -d \
-p 5000:5000 \
--restart=always \
--name registry \
-v /path/to/auth:/auth \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
registry:2
This section provides a comprehensive overview of Docker registries, covering their fundamental concepts, architecture, and practical implementation strategies.