The Docker Registry tool is now well-supported with the mirror feature, which allows you to configure a local mirror service to cache the pull-over image locally so that the other hosts will be able to respond significantly more quickly when pulling again.
Start Registry Mirror Service using Docker-compose
Take Ubuntu, for example, to install Docker and Docker-compose first.
Installing Docker
sudo wget-qo-https://get.docker.com/| Sh
Installing Docker-compose
sudo pip install Docker-compose
After that, the/opt/data/registry directory is created locally as the storage location for the image file, and the/opt/data/redis directory is created as the location where the Redis data is stored.
Write a docker-compose.yml file.
The file will start a registry container to listen on the local 5000 port and use a Redis container as the cache for small files.
The contents are as follows:
# This compose file would start 2 containers:registry and Redis.# Registry Container would listen on host port,# and depend on the Redis container as the cache scheme.Registry: Image: registry:latest Cpu_shares: Ten Environment: - Standalone=false - Mirror_source=https://registry-1.docker.io - Mirror_source_index=https://index.docker.io - Cache_redis_host=redis - cache_redis_port=6379 - Debug=false hostname: Docker-registry links: - Redis:redis Mem_limit: 512m Ports: - "5000:5000" Privileged: false Restart: always User: Root volumes: - /opt/data/registry:/tmp/registryRedis: Image: redis:3.0 Cpu_shares: Ten Expose: - "6379" Mem_limit: 512m Restart: always volumes: - /opt/data/redis:/data
After that, start the service.
Docker-compose up-d
Configuring hosts to use the mirror service
On other hosts, configure the Docker configuration file (for example,/etc/default/docker) to add a row:
docker_opts = "$DOCKER _opts--registry-mirror http://localmirror:5000"
Where Localmirror is replaced with the machine address where the mirror service was just configured.
Then restart the Docker service.
sudo service docker restart
Test
Downloading an image, such as ubuntu:14.04, normally takes more than 10 minutes.
Delete the downloaded image, download it again, less than a minute, and download is complete.
Reprint Please specify: http://blog.csdn.net/yeasy/article/details/46916315
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Configure local mirror services for Docker image downloads