網站首頁 編程語言 正文
Docker啟動失敗報錯Failed?to?start?Docker?Application?Container?Engine的解決辦法_docker
作者:天涯人6 ? 更新時間: 2022-10-03 編程語言前言
在給一臺騰訊云機器安裝docker后發現無法啟動,總是報錯Failed to start Docker Application Container Engine,解決思路分享一下,以免各位童鞋踩坑。
1 安裝Docker
說明:本文僅針對Linux CentOS 7環境下進行講解,Mac版本請在官方下載Docker.dmg安裝(留意:Macbook 沒有yum、systemctl、service等Linux系統的命令,建議下載dmg桌面版Docker使用、配置方便。當然也可以brew install docker自己玩),Windows版本可以下載Docker exe安裝包。
卸載已有 Docker
如果你已經安裝過舊版的 Docker,可以先執行以下命令卸載舊版 Docker:
$ sudo yum remove docker \
? ? ? ? ? ? ? ? ? docker-client \
? ? ? ? ? ? ? ? ? docker-client-latest \
? ? ? ? ? ? ? ? ? docker-common \
? ? ? ? ? ? ? ? ? docker-latest \
? ? ? ? ? ? ? ? ? docker-latest-logrotate \
? ? ? ? ? ? ? ? ? docker-logrotate \
? ? ? ? ? ? ? ? ? docker-engine
安裝 Docker
首次安裝 Docker 之前,需要添加 Docker 安裝源。添加之后,就可以從已經配置好的源去 安裝和更新 Docker。添加 Docker 安裝源的命令如下:
$ sudo yum-config-manager \
? ? --add-repo \
? ? https://download.docker.com/linux/centos/docker-ce.repo
正常情況下,直接安裝最新版本的 Docker 即可,因為最新版本的 Docker 有著更好的穩定性和安全性。也可以使用以下命令安裝最新版本的 Docker:?
$ sudo yum install docker-ce docker-ce-cli containerd.io
注意:Linux CentOS 版本可以通過uname -r 來查看,必須在3.10版本之上才可以使用新版docker。比如我機器上的是3.10.0-1160.62.1.el7.x86_64。
如果想要安裝指定版本的 Docker,可以使用以下命令查看到一批最近的docker歷史版本列表:
$ sudo yum list docker-ce --showduplicates | sort -r
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
Installed Packages
docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.14-3.el7 @docker-ce-stable
docker-ce.x86_64 3:20.10.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
然后選取想要的版本執行以下命令:
$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
安裝完成后,使用以下命令啟動 Docker。
$ sudo systemctl start docker
安裝完成后,我們需要使用以下命令啟動一個 hello world 的容器。
$ sudo docker run hello-world
如果看到輸出了【Hello from Docker!】則說明docker可用。
其它命令比如docker ps -a查看所有鏡像,自行學習即可。
2 Docker安裝故障FAQ
2.1 安裝Docker的版本選擇
在Linux中對不同的安裝方式產生的安裝目錄和文件均不相同,有的會默認放到/sbin或/opt或/usr/local下面,配置文件一般會在/etc下面。Docker也是一樣,如果使用:
sudo yum install docker
來安裝(建議均使用root權限),則安裝的版本為1.13.1。
而如果按照上述第一節的做法,安裝docker-ce版本,則最新是Docker version 20.10.14, build a224086。建議大家安裝docker-ce版本。
2.2 啟動失敗
安裝完畢后,通過systemctl start docker啟動直接報錯:
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
從這個錯誤看不出來什么信息,就去看下運行狀態:
systemctl status docker:
[root@VM_17_5_centos init.d]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Sun 2022-04-10 19:09:56 CST; 11s ago
Docs: https://docs.docker.com
Process: 14592 ExecStart=/usr/bin/dockerd --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 14592 (code=exited, status=1/FAILURE)
Apr 10 19:09:54 VM_17_5_centos systemd[1]: docker.service failed.
Apr 10 19:09:56 VM_17_5_centos systemd[1]: docker.service holdoff time over, scheduling restart.
Apr 10 19:09:56 VM_17_5_centos systemd[1]: Stopped Docker Application Container Engine.
Apr 10 19:09:56 VM_17_5_centos systemd[1]: start request repeated too quickly for docker.service
Apr 10 19:09:56 VM_17_5_centos systemd[1]: Failed to start Docker Application Container Engine.
Apr 10 19:09:56 VM_17_5_centos systemd[1]: Unit docker.service entered failed state.
Apr 10 19:09:56 VM_17_5_centos systemd[1]: docker.service failed.
Apr 10 19:10:00 VM_17_5_centos systemd[1]: start request repeated too quickly for docker.service
Apr 10 19:10:00 VM_17_5_centos systemd[1]: Failed to start Docker Application Container Engine.
Apr 10 19:10:00 VM_17_5_centos systemd[1]: docker.service failed.
貌似也沒發現什么有效的錯誤信息,唯一的一句錯誤是【Failed to start Docker Application Container Engine.】網上其它文章的如下幾個解決方案均無法生效:
1)修改?/etc/docker/daemon.json添加registry-mirrors鏡像地址:這個是用于加速的,跟啟動失敗一般不會有關系。
2)刪除/etc/docker/daemon.json:根本沒必要刪除,用docker官網的鏡像太慢了,肯定要配置國內的鏡像源的。跟啟動失敗也不會有關系。
3)修改Docker Container Engine的配置文件:
有的文章建議去修改/usr/lib/systemd/system/docker.service配置文件,個人覺得是根本沒有必要。雖說從錯誤信息看是有【Process: 14592 ExecStart=/usr/bin/dockerd --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
?Main PID: 14592 (code=exited, status=1/FAILURE)】這樣一句,但本質上原生安裝包不可能剛安裝就有問題還需要用戶自己修改什么。
鑒于上述幾點都無法解決,就想到查看Linux系統操作日志(最后200行就可以排查):
tail -200f /var/log/messages
此時,再次輸入systemctl start docker試圖啟動docker,發現如下錯誤行:
dockerd: failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: Iptables not found
這句話的意思不就是iptables命令無法找到嗎?那試圖看下,cd /sbin目錄查找iptables,竟然的確沒有,用service iptables start也會報錯:iptables: /sbin/iptables does not exist。
但是,/sbin目錄下有個iptables_.sh文件!!是哪個應用修改了這個,不得而知,直接修改:
mv?iptables_??iptables,再啟動:service iptables start,成功了!
這時,再啟動docker:systemctl start docker無輸出但沒報錯了,通過systemctl status docker查看,狀態是Active狀態,表示docker運行正常了!
[root@VM_17_5_centos init.d]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2022-04-10 19:32:05 CST; 41min ago
Docs: https://docs.docker.com
Main PID: 16216 (dockerd)
Tasks: 14
Memory: 38.3M
CGroup: /system.slice/docker.service
└─16216 /usr/bin/dockerd --containerd=/run/containerd/containerd.sock
Apr 10 19:32:04 VM_17_5_centos dockerd[16216]: time="2022-04-10T19:32:04.774479730+08:00" level=info msg="ccRes...=grpc
Apr 10 19:32:04 VM_17_5_centos dockerd[16216]: time="2022-04-10T19:32:04.774491097+08:00" level=info msg="Clien...=grpc
Apr 10 19:32:04 VM_17_5_centos dockerd[16216]: time="2022-04-10T19:32:04.800327122+08:00" level=info msg="[grap...lay2"
Apr 10 19:32:04 VM_17_5_centos dockerd[16216]: time="2022-04-10T19:32:04.805695934+08:00" level=info msg="Loadi...art."
Apr 10 19:32:04 VM_17_5_centos dockerd[16216]: time="2022-04-10T19:32:04.914702098+08:00" level=info msg="Defau...ress"
Apr 10 19:32:05 VM_17_5_centos dockerd[16216]: time="2022-04-10T19:32:05.027046047+08:00" level=info msg="Loadi...one."
Apr 10 19:32:05 VM_17_5_centos dockerd[16216]: time="2022-04-10T19:32:05.070391831+08:00" level=info msg="Docke...10.14
Apr 10 19:32:05 VM_17_5_centos dockerd[16216]: time="2022-04-10T19:32:05.070498814+08:00" level=info msg="Daemo...tion"
Apr 10 19:32:05 VM_17_5_centos systemd[1]: Started Docker Application Container Engine.
Apr 10 19:32:05 VM_17_5_centos dockerd[16216]: time="2022-04-10T19:32:05.107225048+08:00" level=info msg="API l...sock"
Hint: Some lines were ellipsized, use -l to show in full.
其它FAQ疑問歡迎大家持續留言給我來匯總歸納,謝謝~~
總結
原文鏈接:https://blog.csdn.net/Alexanderlc/article/details/124084142
相關推薦
- 2022-07-12 tk mybatis報錯:org.apache.ibatis.binding.BindingExce
- 2023-01-28 Pytorch中torch.cat()函數舉例解析_python
- 2022-10-26 如何查看git分支從哪個源分支拉的_相關技巧
- 2022-11-20 C++?右值引用與?const?關鍵字詳解_C 語言
- 2022-12-03 FFmpeg?Principle學習new_video_stream添加視頻輸出流_Android
- 2022-07-01 react-router-dom?V6的配置使用實踐_React
- 2022-07-12 ERROR:ORA-12543: TNS:destination host unreachable
- 2022-02-28 Chrome控制臺提示“Slow network is detected. Fallback fon
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支