Docker Registry and authentication¶
A Docker registry is a storage and distribution system for named Docker images.^[600-developer__docker__docker.md] The standard, public registry hosted by Docker is Docker Hub (hub.docker.com), but the architecture supports private registries and registry mirrors as well.^[600-developer__docker__docker.md]
In the Docker architecture, the registry acts as the remote service that the Docker daemon interacts with to pull images for running containers or to push locally built images for storage and sharing^[600-developer__docker__docker.md].
Authentication¶
To interact with a registry—particularly to push images or access private repositories—users must authenticate with the Docker service.^[600-developer__docker__docker.md] This is typically accomplished via the command line using:
docker login
This command prompts the user for credentials (username, password, and optionally an email for Docker Hub) and establishes an authenticated session for the current CLI instance^[600-developer__docker__docker.md].
Workflow: Tagging and Pushing¶
The standard workflow for sharing a local image via a registry involves two main steps:
- Tagging: An existing local image is tagged with a new name that includes the user's registry namespace and a repository name^[600-developer__docker__docker.md].
- Syntax:
docker tag <local_image> <username>/<repository>:<tag>
- Syntax:
- Pushing: The tagged image is uploaded to the registry^[600-developer__docker__docker.md].
- Syntax:
docker push <username>/<repository>:<tag>
- Syntax:
Once pushed, the image becomes available on the registry (e.g., in the user's Docker Hub profile) and can be pulled by others or by different machines^[600-developer__docker__docker.md].
Registry Mirrors¶
To optimize performance, especially in regions with latency to the default Docker Hub, Docker can be configured to use a registry mirror^[600-developer__docker__docker.md]. This is configured in the Docker daemon configuration file (daemon.json) by specifying an array of mirror URLs under the registry-mirrors key^[600-developer__docker__docker.md].
Related Concepts¶
- [[Docker image]]
- [[Docker container]]
- [[Docker daemon]]
- CI/CD
Sources¶
- 600-developer__docker__docker.md