Configuring the local mirror service for Docker image downloads

Source: Internet
Author: User
Tags scalar docker registry

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.