亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

docker報錯Container is not running問題及解決

 更新時間:2023年05月18日 15:03:27   作者:曹天驕  
這篇文章主要介紹了docker報錯Container is not running問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

docker報錯Container is not running

我在運行docker exec -it 56b90db5253e /bin/bash報錯。

出現(xiàn)這個問題,是因為Container容器之前已經啟動過了

需要執(zhí)行docker start 56b90db5253e就可以解決了。

docker啟動失敗報錯Failed to start Docker Application Container Engine

在給一臺騰訊云機器安裝docker后發(fā)現(xiàn)無法啟動,總是報錯Failed to start Docker Application Container Engine,解決思路分享一下

安裝Docker

說明:本文僅針對Linux CentOS 7環(huán)境下進行講解,Mac版本請在官方下載Docker.dmg安裝(留意:Macbook 沒有yum、systemctl、service等Linux系統(tǒng)的命令,建議下載dmg桌面版Docker使用、配置方便。

當然也可以brew install docker自己玩),Windows版本可以下載Docker exe安裝包。

卸載已有 Docker

如果你已經安裝過舊版的 Docker,可以先執(zhí)行以下命令卸載舊版 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 有著更好的穩(wěn)定性和安全性。

也可以使用以下命令安裝最新版本的 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?

然后選取想要的版本執(zhí)行以下命令:

$ 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查看所有鏡像,自行學習即可。

Docker安裝故障FAQ

安裝Docker的版本選擇

在Linux中對不同的安裝方式產生的安裝目錄和文件均不相同,有的會默認放到/sbin或/opt或/usr/local下面,配置文件一般會在/etc下面。Docker也是一樣,如果使用:

sudo yum install docker

來安裝(建議均使用root權限),則安裝的版本為1.13.1。

而如果按照上述第一節(jié)的做法,安裝docker-ce版本,則最新是Docker version 20.10.14, build a224086。建議大家安裝docker-ce版本。

啟動失敗

安裝完畢后,通過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.

從這個錯誤看不出來什么信息,就去看下運行狀態(tài):

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.

貌似也沒發(fā)現(xiàn)什么有效的錯誤信息,唯一的一句錯誤是【Failed to start Docker Application Container Engine.】網(wǎng)上其它文章的如下幾個解決方案均無法生效:

1)修改 /etc/docker/daemon.json添加registry-mirrors鏡像地址:這個是用于加速的,跟啟動失敗一般不會有關系。

2)刪除/etc/docker/daemon.json:根本沒必要刪除,用docker官網(wǎng)的鏡像太慢了,肯定要配置國內的鏡像源的。跟啟動失敗也不會有關系。

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系統(tǒng)操作日志(最后200行就可以排查):

tail -200f /var/log/messages

此時,再次輸入systemctl start docker試圖啟動docker,發(fā)現(xiàn)如下錯誤行:

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查看,狀態(tài)是Active狀態(tài),表示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.

總結

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

  • docker掛載本地目錄和數(shù)據(jù)卷容器操作

    docker掛載本地目錄和數(shù)據(jù)卷容器操作

    這篇文章主要介紹了docker掛載本地目錄和數(shù)據(jù)卷容器操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-11-11
  • docker中配置hosts的方法實現(xiàn)

    docker中配置hosts的方法實現(xiàn)

    本文主要介紹了docker中配置hosts的方法實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-04-04
  • Docker下載加速的兩種方式

    Docker下載加速的兩種方式

    本文介紹了使用網(wǎng)易數(shù)帆和阿里云容器鏡像倉庫進行Docker下載加速的兩種方式,第一種是通過網(wǎng)易數(shù)帆官網(wǎng)下載鏡像,第二種是配置阿里云加速器地址到Docker中,這些方法可以幫助用戶更快速地下載Docker鏡像,提升工作效率
    2024-09-09
  • Docker 鏡像優(yōu)化(從1.16GB到22.4MB)

    Docker 鏡像優(yōu)化(從1.16GB到22.4MB)

    在這篇文章中,我將重點討論如何優(yōu)化 Docker 鏡像以使其輕量化,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • docker 查看容器日志命令的實現(xiàn)

    docker 查看容器日志命令的實現(xiàn)

    這篇文章主要介紹了docker 查看容器日志命令的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-12-12
  • docker pull很慢如何解決

    docker pull很慢如何解決

    這篇文章主要介紹了docker pull很慢的解決方法,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • Ubuntu15.10安裝docker和docker-compose教程

    Ubuntu15.10安裝docker和docker-compose教程

    這篇文章主要介紹了Ubuntu15.10安裝docker和docker-compose的教程,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2017-03-03
  • 基于alpine用dockerfile創(chuàng)建的tomcat鏡像的實現(xiàn)

    基于alpine用dockerfile創(chuàng)建的tomcat鏡像的實現(xiàn)

    這篇文章主要介紹了基于alpine用dockerfile創(chuàng)建的tomcat鏡像的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-12-12
  • 從源碼構建docker-ce的過程分析

    從源碼構建docker-ce的過程分析

    這篇文章主要介紹了從源碼構建docker-ce的過程,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-12-12
  • Docker 安裝 MySQL 并實現(xiàn)遠程連接教程

    Docker 安裝 MySQL 并實現(xiàn)遠程連接教程

    這篇文章主要介紹了Docker 安裝 MySQL 并實現(xiàn)遠程連接的教程,幫助大家更好的理解和使用docker容器,感興趣的朋友可以了解下
    2020-09-09

最新評論