Official image acceleration
Function change description
Change content
Only Alibaba Cloud users can use this image acceleration capability on Alibaba Cloud products that support public network access. Only container images within a limited range can be pulled through the image accelerator.
Recommended scheme
It is recommended that you carefully consider the dependency on the Docker Hub container image in the production environment. If you need to use foreign images in the Docker Hub, it is recommended to use Subscribe to overseas source images Function or use Cross domain accelerated pull container image 。 Recommended Product Center The official supported container basic image provided.
Get the image accelerator address
For example: Accelerator address: [system assignment prefix]. mirror.aliyuncs.com
Configure Docker runtime image accelerator
When your Docker version is newer
{ "Registry mirrors": ["<image accelerator address>"] }
When your Docker version is older
Ubuntu 12.04 - 14.04 The location of the Ubuntu configuration file is /etc/default/docker Directory. You only need to add the accelerator configuration item in this configuration file and restart Docker. echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=<your accelerate address>\"" | sudo tee -a /etc/default/docker sudo service docker restart Ubuntu 15.04 - 15.10 The location of the Ubuntu configuration file is /etc/systemd/system/docker.service.d/ Directory. Create an arbitrary *.conf The file can be used as the configuration file. Then add the accelerator configuration item to the configuration file, and restart the Docker. sudo mkdir -p /etc/systemd/system/docker.service.d sudo tee /etc/systemd/system/docker.service.d/mirror.conf <<-'EOF' [Service] ExecStart= ExecStart=/usr/bin/docker daemon -H fd:// --registry-mirror=<your accelerate address> EOF sudo systemctl daemon-reload sudo systemctl restart docker CentOS 7 The configuration mode of CentOS is slightly complicated. You need to first set the default configuration file( /lib/systemd/system/docker.service )Copy to /etc/systemd/system/docker.service 。 Then add the accelerator address to the startup command in the configuration file, and then restart Docker. sudo cp -n /lib/systemd/system/docker.service /etc/systemd/system/docker.service sudo sed -i "s|ExecStart=/usr/bin/docker daemon|ExecStart=/usr/bin/docker daemon --registry-mirror=<your accelerate address>|g" /etc/systemd/system/docker.service sudo sed -i "s|ExecStart=/usr/bin/dockerd|ExecStart=/usr/bin/dockerd --registry-mirror=<your accelerate address>|g" /etc/systemd/system/docker.service sudo systemctl daemon-reload sudo service docker restart Redhat 7 Red Hat 7 configuration accelerator, need to edit /etc/sysconfig/docker Configuration file. stay OPTIONS Add accelerator configuration in configuration item --registry-mirror=<your accelerate address> 。 Final execution sudo service docker restart Command to restart Docker Daemon. Redhat 6/CentOS 6 Docker cannot be installed directly on these two systems. You need to upgrade the kernel. Need to edit when configuring accelerator /etc/sysconfig/docker Configuration file. stay other_args Add accelerator configuration in configuration item --registry-mirror=<your accelerate address> 。 Final execution sudo service docker restart Command to restart Docker Daemon. Docker Toolbox When using Docker Toolbox on Windows and Mac systems, it is recommended to configure the accelerator address when creating a Linux virtual machine. docker-machine create --engine-registry-mirror=<your accelerate address> -d virtualbox default docker-machine env default eval "$(docker-machine env default)" docker info If you have created a virtual machine through docker machine, you need to modify the configuration by logging in to the virtual machine. implement docker-machine ssh <machine-name> Command to log in to the virtual machine. modify /var/lib/boot2docker/profile Files, changing --registry-mirror=<your accelerate address> Add to EXTRA_ARGS Medium. implement sudo /etc/init.d/docker restart Command to restart the Docker service.
Configure Containerd runtime image accelerator
If /etc/containerd/config.toml The configuration file already contains config_path Configuration (e.g "/etc/containerd/cert.d" ), this step is unnecessary; If it does not exist, you can add the following in the configuration file config_path Restart Containerd to make the changes take effect. config_path = "/etc/containerd/certs.d" explain /etc/containerd/config.toml The non default path can be adjusted according to the actual use. If already plugins."io.containerd.grpc.v1.cri".registry , add a line below. Note that Indent is required. If not, it can be written anywhere. [plugins."io.containerd.grpc.v1.cri".registry] config_path = "/etc/containerd/certs.d" After that, you need to check whether there are original mirror related configurations in the configuration file, as follows: [plugins."io.containerd.grpc.v1.cri".registry.mirrors] [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] endpoint = [" https://registry-1.docker.io "] If there is an existing mirror related configuration, it needs to be cleaned. implement systemctl restart containerd Restart Containerd. If the startup fails, execute journalctl -u containerd The reason why the check failed is that the configuration file still has conflicts. You can make adjustments based on the error report.
Specified in step 1 config_path Create in path docker.io/hosts.toml File. Write the following configuration in the file. server = " https://registry-1.docker.io " [host. "$(image accelerator address, such as https://xxx.mirror.aliyuncs.com )"] capabilities = ["pull", "resolve", "push"] Pull the Docker image to verify whether the acceleration is effective. If not, see Reference 。