Docker使用札记 - 使用中遇到的问题总结

1. 启动容器时报错误“: No such file or directory”

一般来说作为容器应用的入口都是entrypoint.sh文件,也就是Dockerfile最后一条指令为是:

ENTRYPOINT ["/entrypoint.sh"]

开始以为是修改的部分哪里不对,将内部内容改为只有一行命令:

date && pwd

  

重新构建并启动容器,仍然不行。网上有说是文件权限的,但是由于Windows系统将文件放入Linux镜像中是默认加了执行权限(+x),详细解释可参看这里

原文:

That warning was added, because the Windows filesystem does not have an option to mark a file as 'executable'. Building a linux image from a Windows machine would therefore break the image if a file has to be marked executable.

For that reason, files are marked executable by default when building from a windows client; the warning is there so that you are notified of that, and (if needed), modify the Dockerfile to change/remove the executable bit afterwards.

所以这解释跳过。

后面再SO看到一条回答才猛然醒悟,这个问题每次在Windows上编写shell脚本都会遇到。问题就出在换行符上,将CRLF改为LF,保持再次构建并启动容器,问题得到解决。

  

猜你喜欢

转载自www.cnblogs.com/xzysaber/p/8882502.html