Docker啟動時的報錯匯總

八個Docker常見故障

https://mp.weixin.qq.com/s/2GNKmRJtBGHhUyVBRbRgeA

八個Docker常見故障

報錯一:error initializing graphdriver

Docker啟動報錯

系統(tǒng)是CentOS 7.2
系統(tǒng)內(nèi)核及docker版本如下 :

[root@docker ~]# uname -r
3.10.0-327.el7.x86_64
[root@docker ~]# 
[root@docker ~]# 
[root@docker ~]# 
[root@docker ~]# docker version
Client:
 Version:   18.04.0-ce
 API version:   1.37
 Go version:    go1.9.4
 Git commit:    3d479c0
 Built: Tue Apr 10 18:21:36 2018
 OS/Arch:   linux/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:  18.04.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   3d479c0
  Built:    Tue Apr 10 18:25:25 2018
  OS/Arch:  linux/amd64
  Experimental: false

啟動報錯提示如下 :

[root@docker ~]# systemctl start docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journ
[root@docker ~]# 
[root@docker ~]# 
[root@docker ~]# 
[root@docker ~]# 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 日 2018-04-22 20:52:39 CST; 5s ago
     Docs: https://docs.docker.com
  Process: 4810 ExecStart=/usr/bin/dockerd (code=exited, status=1/FAILURE)
 Main PID: 4810 (code=exited, status=1/FAILURE)

4月 22 20:52:39 docker.cgy.com systemd[1]: Failed to start Docker Application Container Engine.
4月 22 20:52:39 docker.cgy.com systemd[1]: Unit docker.service entered failed state.
4月 22 20:52:39 docker.cgy.com systemd[1]: docker.service failed.
4月 22 20:52:39 docker.cgy.com systemd[1]: docker.service holdoff time over, scheduling restart.
4月 22 20:52:39 docker.cgy.com systemd[1]: start request repeated too quickly for docker.service
4月 22 20:52:39 docker.cgy.com systemd[1]: Failed to start Docker Application Container Engine.
4月 22 20:52:39 docker.cgy.com systemd[1]: Unit docker.service entered failed state.
4月 22 20:52:39 docker.cgy.com systemd[1]: docker.service failed.

從以上報錯提示信息中也沒看到錯誤的具體原因。然后我又用dockerd來直接啟動惠勒,就在輸出信息最下面看到一條錯誤提示赚抡,如下:

[root@docker ~]# dockerd
INFO[2018-04-22T21:12:46.111704443+08:00] libcontainerd: started new docker-containerd process  pid=5903
INFO[0000] starting containerd                           module=containerd revision=773c489c9c1b21a6d78b5c538cd395416ec50f88 version=v1.0.3

。纠屋。涂臣。。售担。赁遗。省略一部分輸出。族铆。岩四。。哥攘。剖煌。

INFO[0000] loading plugin "io.containerd.grpc.v1.introspection"...  module=containerd type=io.containerd.grpc.v1
INFO[0000] serving...                                    address="/var/run/docker/containerd/docker-containerd-debug.sock" module="containerd/debug"
INFO[0000] serving...                                    address="/var/run/docker/containerd/docker-containerd.sock" module="containerd/grpc"
INFO[0000] containerd successfully booted in 0.002763s   module=containerd
Error starting daemon: error initializing graphdriver: overlay: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior. Reformat the filesystem with ftype=1 to en d_type support. Backing filesystems without d_type support are not supported.

根據(jù)最后的報錯Error starting daemon:搜索到這篇博客,得到解決逝淹。
https://blog.csdn.net/liu9718214/article/details/79134900

具體解決辦法是:

vim /etc/sysconfig/docker
加入如下:

OPTIONS="--selinux-enabled --log-driver=journald --signature-verification=false"

/etc/docker/daemon.json
加入如下內(nèi)容:

{
    "registry-mirrors": ["http://4a1df5ef.m.daocloud.io"],   # 是用來pull容器加速用的耕姊,跟此次問題無關(guān)。
    "storage-driver": "devicemapper"    # 解決此次問題
}

然后重啟docker栅葡,順利解決:

[root@docker ~]# systemctl restart docker
[root@docker ~]# 
[root@docker ~]# 
[root@docker ~]# ps aux | grep docker
root       5922  1.7  1.6 528432 62568 ?        Ssl  21:15   0:00 /usr/bin/dockerd
root       5927  1.1  0.5 356984 22100 ?        Ssl  21:15   0:00 docker-containerd --config /var/run/docker/containerd/containerd.toml
root       6028  0.0  0.0 112664   964 pts/0    S+   21:15   0:00 grep --color=auto docker

報錯二:iptables failed

FirewallD

CentOS-7 中介紹了 firewalld茉兰,firewall的底層是使用iptables進行數(shù)據(jù)過濾,建立在iptables之上妥畏,這可能會與 Docker 產(chǎn)生沖突邦邦。

當(dāng) firewalld 啟動或者重啟的時候,將會從 iptables 中移除 DOCKER 的規(guī)則醉蚁,從而影響了 Docker 的正常工作燃辖。

當(dāng)你使用的是 Systemd 的時候, firewalld 會在 Docker 之前啟動网棍,但是如果你在 Docker 啟動之后再啟動 或者重啟 firewalld 黔龟,你就需要重啟 Docker 進程了。

系統(tǒng):

[root@controller ~]# cat /etc/redhat-release 
CentOS Linux release 7.0.1406 (Core)

報錯提示如下:

[root@controller ~]# docker run -it -P docker.io/nginx
/usr/bin/docker-current: Error response from daemon: driver failed programming external connectivity on endpoint gloomy_kirch (10289e7a87e65771da90cda531951b7339bee9cb5953474460451cd48013aff0): iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 32810 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name.
 (exit status 1).

這是由于在運行這次容器之前,成功啟動過一次氏身,在上次訪問時巍棱,因為防火墻的問題導(dǎo)致不能正常訪問Nginx,所以將iptables的filter表清空了蛋欣,并且重啟過iptables航徙,然后再次運行時,就報了以上錯誤陷虎。

解決辦法

重啟防火墻

#CentOS 7下執(zhí)行
[root@controller ~]# systemctl restart firewalld

再重啟docker守護進程即可

[root@controller ~]# systemctl restart docker

再次在容器中運行一個nginx就不會報錯了

[root@controller ~]# docker run -it --name nginx -p 80:80 -v /www:/wwwroot docker.io/nginx /bin/bash
root@a8a92c8f7760:/# 

報錯三 : Unable to take ownership of thin-pool

docker daemon啟動失數教ぁ:Unable to take ownership of thin-pool

Apr 27 13:51:59 master systemd: Started Docker Storage Setup.
Apr 27 13:51:59 master systemd: Starting Docker Application Container Engine...
Apr 27 13:51:59 master dockerd-current: time="2018-04-27T13:51:59.088441356+08:00" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found"
Apr 27 13:51:59 master dockerd-current: time="2018-04-27T13:51:59.091166189+08:00" level=info msg="libcontainerd: new containerd process, pid: 20930"
Apr 27 13:52:00 master dockerd-current: Error starting daemon: error initializing graphdriver: devmapper: Unable to take ownership of thin-pool (docker--vg-docker--pool) that already has used data blocks
Apr 27 13:52:00 master systemd: docker.service: main process exited, code=exited, status=1/FAILURE
Apr 27 13:52:00 master systemd: Failed to start Docker Application Container Engine.
Apr 27 13:52:00 master systemd: Unit docker.service entered failed state.
Apr 27 13:52:00 master systemd: docker.service failed

原因: /var/lib/docker/devicemapper/metadata/ 內(nèi)metadata丟失

workaround:

https://bugzilla.redhat.com/show_bug.cgi?id=1321640#c5

Eric Paris 2016-04-27 08:20:10 EDT

I feel like the kcs kinda misses telling users the actual problem. Nor does it really make it clear the solution.

IF you are using device mapper (instead of loopback) /var/lib/docker contains metadata informing docker about the contents of the device mapper storage area. If you delete /var/lib/docker that metadata is lost. Docker is then able to detect that the thin pool has data but docker is unable to make use of that information. The only solution is to delete the thin pool and recreate it so that both the thin pool and the metadata in /var/lib/docker will be empty.

解決辦法:

  1. 執(zhí)行命令:rm -rf /var/lib/docker/*
  2. 執(zhí)行命令:rm -rf /etc/sysconfig/docker-storage
  3. 執(zhí)行命令:lvremove /dev/docker-vg/docker-pool
  4. 使用現(xiàn)有的docker-vg LVM卷組:
cat <<EOF > /etc/sysconfig/docker-storage-setup
VG=docker-vg
EOF
  1. 執(zhí)行命令:docker-storage-setup
  2. 重啟docker即可:systemctl start docker

報錯四: write /sys/fs/cgroup/cpuset/docker/cpuset.cpus: invalid argument

docker run運行容器時報出如下錯誤:

[root@backup-system cpu]# docker run -ti --name hkp_ubuntu  --cpuset-cpus=0-3 ubuntu bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:326: applying cgroup configuration for process caused: failed to write "0-3\n" to "/sys/fs/cgroup/cpuset/docker/cpuset.cpus": write /sys/fs/cgroup/cpuset/docker/cpuset.cpus: invalid argument: unknown.

這個錯誤是因為該cgroup的cpu正在被其它cgroup使用,所以不能設(shè)置獨占尚猿。
因此需要先檢查并調(diào)整各個cgroup的cpuset.cpus窝稿,確保當(dāng)前cgroup所用的cpu的確只分配給它了,那么此時就可以設(shè)置cpu_exclusive獨占了凿掂。

當(dāng)前的具體原因是做實驗在 /sys/fs/cgroup/cpuset/新建了 container目錄伴榔,并把 container/cpuset.cpus 設(shè)置為了 0-3

[root@backup-system docker]# cat /sys/fs/cgroup/cpuset/container/cpuset.cpus 
0-3

解決方法
/sys/fs/cgroup/cpuset/container/cpuset.cpus設(shè)為空后,上述問題得到解決庄萎。

具體原因可查看此篇博客:https://www.lenky.info/archives/2019/03/2679

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末踪少,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子惨恭,更是在濱河造成了極大的恐慌秉馏,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,284評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件脱羡,死亡現(xiàn)場離奇詭異萝究,居然都是意外死亡,警方通過查閱死者的電腦和手機锉罐,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,115評論 3 395
  • 文/潘曉璐 我一進店門帆竹,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人脓规,你說我怎么就攤上這事栽连。” “怎么了侨舆?”我有些...
    開封第一講書人閱讀 164,614評論 0 354
  • 文/不壞的土叔 我叫張陵秒紧,是天一觀的道長。 經(jīng)常有香客問我挨下,道長熔恢,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,671評論 1 293
  • 正文 為了忘掉前任臭笆,我火速辦了婚禮叙淌,結(jié)果婚禮上秤掌,老公的妹妹穿的比我還像新娘。我一直安慰自己鹰霍,他們只是感情好闻鉴,可當(dāng)我...
    茶點故事閱讀 67,699評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著茂洒,像睡著了一般孟岛。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上获黔,一...
    開封第一講書人閱讀 51,562評論 1 305
  • 那天蚀苛,我揣著相機與錄音在验,去河邊找鬼玷氏。 笑死,一個胖子當(dāng)著我的面吹牛腋舌,可吹牛的內(nèi)容都是我干的盏触。 我是一名探鬼主播,決...
    沈念sama閱讀 40,309評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼块饺,長吁一口氣:“原來是場噩夢啊……” “哼赞辩!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起授艰,我...
    開封第一講書人閱讀 39,223評論 0 276
  • 序言:老撾萬榮一對情侶失蹤辨嗽,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后淮腾,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體糟需,經(jīng)...
    沈念sama閱讀 45,668評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,859評論 3 336
  • 正文 我和宋清朗相戀三年谷朝,在試婚紗的時候發(fā)現(xiàn)自己被綠了洲押。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,981評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡圆凰,死狀恐怖杈帐,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情专钉,我是刑警寧澤挑童,帶...
    沈念sama閱讀 35,705評論 5 347
  • 正文 年R本政府宣布,位于F島的核電站跃须,受9級特大地震影響站叼,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜回怜,卻給世界環(huán)境...
    茶點故事閱讀 41,310評論 3 330
  • 文/蒙蒙 一大年、第九天 我趴在偏房一處隱蔽的房頂上張望换薄。 院中可真熱鬧,春花似錦翔试、人聲如沸轻要。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,904評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽冲泥。三九已至,卻和暖如春壁涎,著一層夾襖步出監(jiān)牢的瞬間凡恍,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,023評論 1 270
  • 我被黑心中介騙來泰國打工怔球, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留嚼酝,地道東北人。 一個月前我還...
    沈念sama閱讀 48,146評論 3 370
  • 正文 我出身青樓竟坛,卻偏偏與公主長得像闽巩,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子担汤,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,933評論 2 355

推薦閱讀更多精彩內(nèi)容