How to pull the image by Docker
This article mainly introduces Docker how to pull the mirror image, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
1. Pull the image by docker pull
When pulling an image using $docker pull {IMAGE_NAME}, there are two situations:
The first slash in IMAGE_NAME is preceded by a domain name identification
Docker recognizes IMAGE_NAME as a mirror with a domain name. For example, myregistry.io/space1/image1:latest, Docker will go to the server pointed to by myregistry.io to request mirror data. A Docker image is divided into many layers. If the layer exists locally, it will not be pulled again.
There is no domain name identification before the first slash in IMAGE_NAME
Docker splices the IMAGE_NAME into docker.io/IMAGE_NAME request mirror data. In fact, $docker pull docker.io/shaowenchen/images1 has the same effect as $docker pull shaowenchen/images1. For the images provided by DockerHub, the domestic access speed is slow and can be accelerated by adding mirror sources.
There may be two problems when pulling the image:
1. Pull a private image and prompt to log in
You can log in directly using docker login. In non-interactive scenarios, you can execute:
$echo "$DOCKER_PASSWORD" | docker login $REGISTRY-u "$DOCKER_USERNAME"-- password-stdin
2. Image repository certificate error
If the image warehouse server is specified in IMAGE_NAME, but the server does not provide a valid https service, you need to configure it as follows:
In the / etc/docker/daemon.json file, add:
{"insecure-registries": ["core.harbor.chenshaowen.com:5000"]}
Restarting Docker takes effect.
two。 Modify the mirror source to accelerate the pull of the image
Modify the configuration file daemon.json of Docker
In the / etc/docker/daemon.json file, add the mirror source
{"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]}"
Modify the systemd parameter of Docker
Edit the file / usr/lib/systemd/system/docker.service, and on the line where ExecStart is located, add the registry-mirror parameter.
ExecStart=...-- registry-mirror= https://docker.mirrors.ustc.edu.cn
Restarting Docker takes effect.
Thank you for reading this article carefully. I hope the article "how to pull the Image from Docker" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!