「Docker」- 常见错误汇总

更新日期:2021年04月02日

#6 构建镜像是,执行 chown -R 非常慢

Docker images and files chown
Recursive chown is really slow #388

问题描述:
如果在Dockefile中包含chown -R /path/foo命令,则构建镜像时间将非常久。

问题原因
由与Docker使用写时复制策略,所以chown命令执行时,会将上层镜像文件全部复制到当前层,然后再修改权限,再写入文件系统。

在「使用chown -R命令」与「不使用chown -R命令」情况下,分别构建两个镜像,使用docker history命令可以看到镜像层。你会发现在包含chown -R命令时,镜像层将消耗很多空间。

解决办法:
不应该使用chown之类大批量修改文件的命令。

#3 exec user process caused "exec format error"

exec user process caused "exec format error" when run container with CMD on RHEL
启动容器时产生该错误。

该镜像的CMD是一个SHELL脚本,该将本没有添加「shebang」,导致运行时无法识别脚格式。

在启动脚本中添加shebang头,即「#!/bin/sh」

#2 x509: cannot validate certificate because of not containing any IP SANs

TODO 使用自签名的SSL证书情况下,如何登录Registry

#3 Error response from daemon when pulling a specific image tag from DTR

-「Error response from daemon when pulling a specific image tag from DTR
TODO Error response from daemon: manifest for xxx/xxx/xxx:xxx not found

#1 想不到的错误

在我的Debain中运行:docker run --rm -t -i centos:6.10 /bin/bash

直接退出,退出码为139;但是执行其他的ls或者cat之类的命令是正常的。

centos:6.10的镜像也可以在CentOS Linux release 7.4.1708 (Core)上正常运行;

使用dmesg查看系统输出:

[2023147.282206] docker0: port 2(veth2016d06) entered blocking state
[2023147.282209] docker0: port 2(veth2016d06) entered disabled state
[2023147.282463] device veth2016d06 entered promiscuous mode
[2023147.286060] IPv6: ADDRCONF(NETDEV_UP): veth2016d06: link is not ready
[2023147.967258] eth0: renamed from veth4bc81c0
[2023147.991101] IPv6: ADDRCONF(NETDEV_CHANGE): veth2016d06: link becomes ready
[2023147.991191] docker0: port 2(veth2016d06) entered blocking state
[2023147.991196] docker0: port 2(veth2016d06) entered forwarding state
[2023148.163593] bash[21306] vsyscall attempted with vsyscall=none ip:ffffffffff600400 cs:33 sp:7ffce2f568d8 ax:ffffffffff600400 si:7ffce2f57f76 di:0
[2023148.163598] bash[21306]: segfault at ffffffffff600400 ip ffffffffff600400 sp 00007ffce2f568d8 error 15
[2023148.363842] docker0: port 2(veth2016d06) entered disabled state
[2023148.363977] veth4bc81c0: renamed from eth0
[2023148.487894] docker0: port 2(veth2016d06) entered disabled state
[2023148.493036] device veth2016d06 left promiscuous mode
[2023148.493044] docker0: port 2(veth2016d06) entered disabled state

应该是内核版本导致的系统调用失败(我的猜测)。具体原因就不知道了,不是那个方向啊。

参考文献

Docker frequently asked questions (FAQ) | Docker Documentation


ToC

#6 构建镜像是,执行 chown -R 非常慢

#3 exec user process caused "exec format error"

#2 x509: cannot validate certificate because of not containing any IP SANs

#3 Error response from daemon when pulling a specific image tag from DTR

#1 想不到的错误

参考文献