Docker Registry mirroring¶
Docker registry mirroring is a configuration mechanism used to redirect Docker image pull requests from the default public registry (Docker Hub) to a local or third-party caching server^[600-developer-docker-docker.md]. This is primarily used to accelerate download speeds and ensure network reliability.
Configuration¶
To configure a Docker daemon to use a registry mirror, the daemon.json configuration file must be edited^[600-developer-docker-docker.md].
Linux Setup¶
On Linux systems, the configuration file is typically located at /etc/docker/daemon.json^[600-developer-docker-docker.md]. The mirror URLs are defined within the registry-mirrors key:
{
"registry-mirrors": [
"https://hub.docker.com/",
"https://registry.docker-cn.com"
]
}
The source example lists https://hub.docker.com/ and https://registry.docker-cn.com as valid URLs^[600-developer-docker-docker.md]. After modifying this file, the Docker daemon generally needs to be restarted for the changes to take effect.
How it works¶
When a mirror is configured, the Docker daemon attempts to fetch images from the specified mirror URL(s) first^[600-developer-docker-docker.md]. If the mirror has the cached image, it serves it; otherwise, it may proxy the request to the original registry.
Related Concepts¶
- [[Docker]]
- [[Docker Hub]]
Sources¶
^[600-developer-docker-docker.md]