一次诡异的docker错误调试

2019-04-07  本文已影响0人  ZeroWind

源自小伙伴的求助,虽然没能定位到最终的原因,调试的过程也比较有意思

缘起

小伙伴求助我,同一个docker镜像在测试机器上可以运行,在阿里云上运行提示用户不存在。

在阿里云上运行提示如下:

# docker run --rm -it image:tag
docker: Error response from daemon: linux spec user: unable to find user www-data: no matching entries in passwd file.
ERRO[0000] error waiting for container: context canceled

调试过程

换成用root启动,依然提示找不到用户

# docker run --rm -it --user root image:tag
docker: Error response from daemon: linux spec user: unable to find user root: no matching entries in passwd file.

换一种方式启动,错误提示变了

# docker run --rm -it --user $(id -u) image:tag
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"docker-php-entrypoint\": executable file not found in $PATH": unknown.

换一个entrypoint试试看

# docker run --rm -it --user $(id -u) --entrypoint 'ls' image:tag
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"ls\": executable file not found in $PATH": unknown.

# docker run --rm -it --user $(id -u) --entrypoint '/bin/ls' image:tag
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/bin/ls\": stat /bin/ls: no such file or directory": unknown.

/bin/ls挂载到容器内试试

# docker run --rm -it --user $(id -u) -v '/bin/ls':'/bin/ls' --entrypoint '/bin/ls' image:tag
standard_init_linux.go:190: exec user process caused "no such file or directory"

山穷水尽

暂时没找到办法进一步的追踪。通过docker inspectdocker history均看不出镜像的异常。

通过docker logs也看不到容器启动中的其他错误。

柳暗花明

别的小伙伴帮忙找到了这个issue: Error response from daemon: OCI runtime create failed - when running a Node.js Docker image

虽然错误类型不太一致,发现我一直忘记查看docker daemon的日志!!!!

通过journalctl -fu docker.service查看错误日志,发现和issue中的错误一致。

... level=error msg="stream copy error: reading from a closed fifo"

可能是docker的一个未修复的BUG。

TODO

为何--user root时会查找passwd文件,--user $(id -u)可以跳过passwd文件

上一篇下一篇

猜你喜欢

热点阅读