文章目录
- Docker镜像换源
-
- [1 更新Docker镜像源](#1 更新Docker镜像源)
- [2 重启Docker服务](#2 重启Docker服务)
- [3 验证换源是否成功](#3 验证换源是否成功)
Docker镜像换源
环境: Ubuntu22.04
由于各种网络政策,在国内访问DockerHub速度会非常缓慢,大家一般都会采取更换镜像源的方式来进行加速。
1 更新Docker镜像源
直接将下列文本粘贴到终端中,然后回车运行即可。
sh
pzs@pzs-jammy:~$ sudo tee /etc/docker/daemon.json << 'EOF'
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://docker.imgdb.de",
"https://docker-0.unsee.tech",
"https://docker.hlmirror.com",
"https://cjie.eu.org"
]
}
EOF
注:上面的镜像不一定能够一直使用,如果不能使用,请自行找其他镜像源!!!
2 重启Docker服务
sh
pzs@pzs-jammy:~$ sudo systemctl daemon-reload
pzs@pzs-jammy:~$ sudo systemctl restart docker
3 验证换源是否成功
sh
pzs@pzs-jammy:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d5e71e642bf5: Download complete
4f55086f7dd0: Pull complete
Digest: sha256:5e23090353324d887c48ad5e5c56d294eab81588df9605b07d1afe895f9cc8f8
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/