首页/云/Docker 容器速查/no such file or directory:CRLF 与动态库
容器排障52 条

no such file or directory:CRLF 与动态库

standard_init_linux.go ... exec user process caused: no such file or directory:看似文件在但报不存在,典型原因是脚本 CRLF 换行、shebang 解释器缺失或动态链接库不全。

Docker 容器速查云更新于 2026-10-12
原因一Windows 编辑的脚本带 CRLF,shebang 识别失败
原因二解释器路径不存在(如 /bin/bash 在 alpine)
原因三二进制依赖的动态库缺失

示例

示例
file entrypoint.sh
head -c 80 entrypoint.sh | od -c | head -3
dos2unix entrypoint.sh
docker run --rm --entrypoint sh app/web:1.0 -c 'ldd /app/bin/server 2>/dev/null | grep not || true'
Git 仓库加 .gitattributes(脚本 LF)能从源头省掉这类问题。

易错点

  • 宿主编译的二进制拷进更薄的基础镜像常缺 libc 等库,换镜像或静态编译
  • 这个报错与文件真不存在难以区分,file 与 od 两条命令先排格式问题

数据来源与参考

  • Docker 官方文档:Building best practices(docs.docker.com/develop)
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌