一、添加Docker国内镜像
1、修改 /etc/docker/daemon.json
设置 registry mirror,具体命令如下:
sudo vim /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://docker.1ms.run",
"https://docker.xuanyuan.me",
"https://hub.rat.dev",
"https://docker.1panel.live"
]
}
EOF
2、重启docker:
systemctl daemon-reload
systemctl restart docker
二、添加Podman国内镜像
1、修改 /etc/containers/registries.conf.d/999-podman-machine.conf
999-podman-machine.conf 这个文件名字可能每台机子有自己的名称,可以在路径下找到自己的名字。
设置 registry mirror,具体命令如下:
# enter into the podman virtual machine
podman machine ssh
# change the podman registries
sudo vi /etc/containers/registries.conf.d/999-podman-machine.conf
# ----------contents as follows -----------------
unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
location = "docker.1ms.run"
[[registry]]
prefix = "docker.io"
location = "hub.rat.dev"
[[registry]]
prefix = "docker.io"
location = "docker.xuanyuan.me"
[[registry]]
prefix = "docker.io"
location = "docker.1panel.live"
我的环境时windows11下的podman,所以需要podman machine,纯linux环境可以跳过podman machine这步。
2. 重新podman machine
podman machine stop
podman machine start
3. 测试是否成功
podman pull docker.1ms.run/library/hello-world
Trying to pull docker.1ms.run/library/hello-world:latest...
Getting image source signatures
Copying blob sha256:e6590344b1a5dc518829d6ea1524fc12f8bcd14ee9a02aa6ad8360cce3a9a9e9
Copying config sha256:74cc54e27dc41bb10dc4b2226072d469509f2f22f1a3ce74f4a59661a1d44602
Writing manifest to image destination
74cc54e27dc41bb10dc4b2226072d469509f2f22f1a3ce74f4a59661a1d44602
输出所示,表示registry配置成功。
三、docker/podman search 镜像名 报错时
通过docker/podman search 镜像名 不能查找的时候,通常报错:Get "https://index.docker.io/v2/" ...timeout.
podman search hello-world
Error: 2 errors occurred:
* couldn't search registry "docker.io": pinging container registry index.docker.io: Get "https://index.docker.io/v2/": dial tcp 202.160.130.52:443: i/o timeout
* couldn't search registry "xuanyuan.me": pinging container registry xuanyuan.me: StatusCode: 404, "<html>\r\n<head><title>404 Not Found</title></head>\r..."
可以尝试来网站上手动查找自己需要的镜像,然后使用pull命令+镜像限定名称获得。
https://docker.1ms.run
https://docker.xuanyuan.me