一、添加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 stoppodman 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
DockerHub鏡像加速器 - 免費Docker鏡像源國內加速 - DockerHub加速國內解決方案