How to modify the docker pull mirror source

  • 2020-06-12 11:14:42
  • OfStack

Docker Hub Mirror is the world's largest Docker Registry(Docker Hub) mirror agent in China. Docker Hub Mirror caches many images on domestic servers for Chinese users

When the user's Docker has set the parameter -- ES14en-ES15en, when the user's Docker pulls down the image, it first goes to Docker Hub Mirror to look for the image. If it hits, the image has been cached in Docker Hub Mirror, and the user directly downloads it from Docker Hub Mirror. If the image is not cached, then Docker Hub Mirror is first driven to Docker Hub to download the image, cache it, and finally let the user download the image from Docker Hub Miorror

Ubuntu:

Install or upgrade Docker

Docker Hub Mirror only supports Docker Hub Mirror above version 1.3.2. If you have not installed Docker or the version is too low, please install or upgrade the version

Configure Docker Hub Mirror


sudo echo "DOCKER_OPTS=\"$DOCKER_OPTS --registry-mirror=http://xxx.m.daocloud.io\"" >> /etc/default/docker service docker restart

Please replace xxx with the link name of the Mirror address generated for you after you have registered on DaoCloud. This script adds -- ES64en-ES65en to your Docker profile /etc/defaults/docker

Download the official Ubuntu image


docker pull ubuntu 

CentOS:

Install or upgrade Docker

Docker 1.3.2 supports Docker Hub Mirror only. If you have not installed Docker or the version is too low, please install or upgrade the version

Configure Docker Hub Mirror


sudo sed -i 's|OPTIONS='--registry-mirror=true'|OPTIONS='--registry-mirror=http://xxx.m.daocloud.io|g' /etc/sysconfig/docker && service docker restart

MAC:

Install or upgrade Boot2Docker under MAC

Docker 1.3.2 supports Docker Hub Mirror only, if you have not installed Docker or the version is too low, please install or upgrade the version.

Configure Docker Hub Mirror

Please make sure your Boot2Docker is up and running


boot2docker ssh sudo su echo "EXTRA_ARGS=\"--registry-mirror=http://xxx.m.daocloud.io\"" >> /var/lib/boot2docker/profile && exit exit boot2docker restart

Windows:

Install or upgrade Boot2Docker under MAC version

Docker 1.3.2 supports Docker Hub Mirror only. If you have not installed Docker or the version is too low, please install or upgrade the version.

Configure Docker Hub Mirror

Go to Boot2Docker Start Shell and execute


sudo su echo "EXTRA_ARGS=\"--registry-mirror=http://xxx.m.daocloud.io\"" >> /var/lib/boot2docker/profile exit # Restart the Boot2Docker

The experimental environment of this paper is centos


vim /etc/sysconfig/docker
OPTIONS='--registry-mirror=http://9zkjjecg.mirror.aliyuncs.com'
systemctl restart docker.service

Download the Ubuntu image


docker pull ubuntu

Start the container with the following warning


[root@linux-node1 sysconfig]# docker run -i -t ubuntu /bin/bash
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.

Solution: vim /etc/sysconfig/ ES182en-ES183en add the following sentence


DOCKER_STORAGE_OPTIONS="--storage-opt dm.no_warn_on_loop_devices=true"


Related articles: