记一次启动容器失败
# 记一次启动容器失败
一个未解之谜....
# 起因
在 2024-7-1 日晚,突然有个粉丝加我微信,说是付费咨询一个问题。
首先是一个报错截图:
完整的命令如下:
据了解,今天他已经新建了几个容器,都是能正常启动的。此外,这个 iStore OS 之前还真没听过,搜了下应该是一个定制版的 OS,用于搭建 NAS 的魔改版。
接下来是排查过程。
# 排查过程
# 目录问题?
一开是我以为是目录没有新建的问题,并且使用的用户没有权限创建;
但是新建了目录后,仍然报错,并且使用的是 root 用户,目录权限也检查过是有的;
mkdir /mnt/sda1/docker/calibre/data
mkdir /mnt/sda1/docker/calibre/library
2
# 磁盘空间不足?
使用 df -h 看了下,磁盘空间还是有的,并且这个镜像也不大,700 多 M
# 镜像源问题?
问了下用的什么镜像源,都是国内的,而且之前不少容器都已经成功创建了,应该也不是;
https://docker.m.daocloud.io
https://hub-mirror.c.163.com
https://ustc-edu-cn.mirror.aliyuncs.co
2
3
ps -a 也能看到正在运行的容器:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
719279002f30 fogforest/yesplaymusic "/docker-entrypoint.…" 13 hours ago Up 13 hours 0.0.0.0:7900->80/tcp, :::7900->80/tcp yesplaymusic
0329121ab483 emby/embyserver:4.8.0.56 "/init" 30 hours ago Up 30 hours emby
a14d973f62d4 ddsderek/xiaoya-emd:latest "tini -g -- /entrypo…" 32 hours ago Up 32 hours xiaoya-emd
2737ae0c2728 xiaoyaliu/alist:hostmode "/entrypoint.sh /opt…" 32 hours ago Up 30 hours xiaoya
c43ce2bc319e advplyr/audiobookshelf "tini -- node index.…" 2 days ago Up 2 days 0.0.0.0:13378->80/tcp, :::13378->80/tcp audiobookshelf
7cde11633e17 alpine:3.18.2 "sh -c 'if [ -f /etc…" 2 days ago Up 2 days xiaoyakeeper
2
3
4
5
6
7
# 内核版本问题?
搜索了下报错信息,在 Stack Overflow 上看到有类似的,说是内核版本问题,2.6 版本以下的不支持。
原帖:https://stackoverflow.com/questions/34796125/error-response-from-daemon-cannot-start-container-no-such-file-or-directory
回答 1:
To run Docker on Oracle linux, you need the "Unbreakable Enterprise Kernel" 3.8 or higher (opens new window) installed.
After that, you can follow the installation procedure in the documentation (opens new window)
Note that kernel 2.6 is no longer supported by Docker since Docker 1.8.0; the last available builds for 2.6 based distro's (RHEL6/CentOS6) is docker 1.7.1
回答 2:
This is a known issue (opens new window) with kernels order than 2.6.32-431 (opens new window). Reason being:
"Since it is also not possible to get systemd up on RH6 using lxc."
I tried testing in CentOS6.3 (which is very similar to RedHat/OracleLinux) which had 2.6.32-279.5.2.el6.x86_64 kernel and got the same problem (More information was in the logs).
[user@localhost ~]$ docker -v Docker version 1.7.1, build 786b29d [user@localhost ~]$ docker run hello-world Error response from daemon: Cannot start container 6853f515819f8928fa5a9b4f2b2af2c117e2c6183dbc1f9ea59c29a28adc45a8: no such file or directory [user@localhost ~]$
1
2
3
4
5There is however a work around by upgrading your kernel if that is an option. So I upgraded the kernel (2.6.32-573.12.1.el6.x86_64) and docker works !
PS: Do not do this in production systems without testing.
[root@localhost ~]# yum -y update kernel Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: ftp.crc.dk ... Dependency Updated: dracut.noarch 0:004-388.el6 dracut-kernel.noarch 0:004-388.el6 dracut-network.noarch 0:004-388.el6 kernel-firmware.noarch 0:2.6.32-573.12.1.el6 Complete! [user@localhost ~]$ reboot ... [user@localhost ~]$ uname -r 2.6.32-573.12.1.el6.x86_64 [user@localhost ~]$ docker run hello-world Hello from Docker. ... For more examples and ideas, visit: https://docs.docker.com/userguide/ [user@localhost ~]$
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21So, I recommend you to check if you have an older version of kernel < 2.6.32-431 and do a kernel upgrade and test it out.
然后我让他看了下内核版本,也不太像是很低的:
uname -r
5.10.201
2
# 启动 hello-world 都不行
最后我怀疑是不是 Docker 出现了问题,让他试着拉取其他镜像,发现都报错了;就连最基本的 hello-world 都是:
root@iStoreOS:~# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:94323f3e5e09a8b9515d74337010375a456c909543e1ff1538f5116d38ab3989
Status: Downloaded newer image for hello-world:latest
docker: Error response from daemon: mkdir /mnt/sda1/docker/containers/03be936037db1667a30cf9eb94ddf400adc0caeae4ccccd4e35e5c98ea9050b4: no such file or directory.
See 'docker run --help'.
2
3
4
5
6
7
8
# 重启大法
实在没辙,试试重启大法吧... 但是就连重启,也 是一波三折:
# 对于基于 Systemd 的系统(如 Ubuntu 16.04 及以上版本,Debian 8 及以上版本):
systemctl restart docker
-ash: systemctl: not found
# 对于基于 SysVinit 的系统(如 CentOS 6,Debian 7):
service docker restart
Service "docker" not found
2
3
4
5
6
7
8
难道这个魔改的 OS,安装 Docker 后改名了?试试 ps -ef
:
root@iStoreOS:~# ps -ef | grep docker
ps: unrecognized option: e
BusyBox v1.35.0 (2023-07-05 07:27:39 UTC) multi-call binary.
Usage: ps
Show list of processes
w Wide output
2
3
4
5
6
7
8
9
得,那就试试 -w 参数:
ps -w | grep docker」
—————————
Show list of processes
w Wide output
root@iStoreOS:~# ps -w | grep docker
3908 root 1124 S grep docker
9361 root 697m S /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 7900 -container-ip 172.17.0.3 -container-por
9368 root 696m S /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 7900 -container-ip 172.17.0.3 -container-port 80
14663 root 697m S /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 13378 -container-ip 172.17.0.2 -container-po
14671 root 696m S /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 13378 -container-ip 172.17.0.2 -container-port 80
26599 root 748m S /usr/bin/dockerd --config-file=/tmp/dockerd/daemon.json
26633 root 750m S containerd --config /var/run/docker/containerd/containerd.toml --log-level warn
2
3
4
5
6
7
8
9
10
11
12
13
最后看到一行 dockerd
,那就试试重启这个,好消息是重启成功了:
root@iStoreOS:~# service dockerd restart
root@iStoreOS:~#
2
然后,跑 hello-world,以及一开始那个错误的镜像,也成功了:
docker run hello-world」
—————————
Hello from Docker!
This message shows that your installation appears to be working correctly.
...........
2
3
4
5
此外,还有一点很奇怪,之前正在运行的容器,都不见了.....
root@iStoreOS:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bf9379ea3e74 lscr.io/linuxserver/calibre-web:latest "/init" 2 minutes ago Up 2 minutes 0.0.0.0:8083->8083/tcp, :::8083->8083/tcp calibre-web
bc2a4b940591 hello-world "/hello" 3 minutes ago Exited (0) 3 minutes ago competent_mirzakhani
2
3
4
按理说,重启的话之前的容器是会停止的,重启 Docker 后再重启容器即可。
但是这个魔改的操作系统就很奇怪,之前的容器都没有了。
好在我先提前确定了下,这几个容器可以重新搭建没问题,不然就麻烦了😂。
# 最后
前前后后折腾了大半个小时(老哥也没学过编程,沟通起来有点费时),虽然还是不知道为什么会出现这个错误,但好歹是将问题解决了。
一般来说,一些小问题我都是直接解答的,而且老哥也很配合;但老哥最后还是打赏了,那我也就不客气 😏。
最后,谨以此文记录这个未解之谜,我还是感到很奇怪,Docker 是跨平台的,为什么会出现这些问题呢?....