Docker拉取鏡像超時
報錯
Unable to find image 'dpanel/dpanel:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/ ": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
解決方式
在etc/docker/
目錄下創建daemon.json
文件,將下面內容粘貼進去。
{"registry-mirrors": ["https://registry.cn-hangzhou.aliyuncs.com","https://do.nark.eu.org","https://dc.j8.work","https://docker.m.daocloud.io","https://dockerproxy.com","https://docker.mirrors.ustc.edu.cn","https://docker.nju.edu.cn"]
}
docker
重新加載文件,然后重啟;
sudo systemctl daemon-reload
sudo systemctl restart docker
命令方式操作
sudo tee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://registry.cn-hangzhou.aliyuncs.com","https://do.nark.eu.org","https://dc.j8.work","https://docker.m.daocloud.io","https://dockerproxy.com","https://docker.mirrors.ustc.edu.cn","https://docker.nju.edu.cn"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
鏡像被多個倉庫引用
報錯
Error response from daemon: conflict: unable to delete c2a6a40506b9 (must be forced) - image is referenced in multiple repositories
解決方式
- 查看鏡像引用
docker images
- 刪除鏡像引用
docker rmi <鏡像名稱>:<標簽>
- 強制刪除鏡像
如果鏡像仍然無法刪除,可以使用 -f 或 --force 選項強制刪除:
docker rmi -f <鏡像名稱/id>
Docker未正確登錄到鏡像倉庫,或權限不足
報錯:
docker push crpi-5qc4odiityxeoecl.cn-hangzhou.personal.cr.aliyuncs.com/aliyun-namespace-lym/dpanel/dpanel:latest
The push refers to repository [crpi-5qc4odiityxeoecl.cn-hangzhou.personal.cr.aliyuncs.com/aliyun-namespace-lym/dpanel/dpanel]
5f70bf18a086: Preparing
663fbf8d6b31: Preparing
37ae894d7828: Preparing
618509a5037e: Preparing
645a17712757: Preparing
e48cf4869d45: Waiting
a49ad3c60d1c: Waiting
3ac371982ee8: Waiting
08000c18d16d: Waiting
denied: requested access to the resource is denied
解決方式
- 登錄到目標鏡像倉庫
docker login xxx.xxx.xxx.cr.aliyuncs.com
- 重新配置鏡像倉庫
如果問題仍然存在,可以嘗試重新配置鏡像倉庫
2.1. 刪除鏡像倉庫。
2.2. 重新創建鏡像倉庫。
2.3. 重新推送鏡像
docker-compose.yml
文件配置錯誤
報錯
compose up
yaml: unmarshal errors:line 109: mapping key "networks" already defined at line 107
解決
確保 networks
部分只定義一次。如果需要定義多個網絡,應該將它們放在同一個 networks
部分下。例如:
networks:my_network:driver: bridgeanother_network:driver: bridge
未在 docker-compose.yml
文件所在目錄啟動
報錯
docker compose up
no configuration file provided: not found
解決
指定配置文件路徑
docker compose -f /path/to/docker-compose.yml up