简体   繁体   English

尝试运行 Docker 映像时出现“exec 用户进程导致“没有这样的文件或目录”错误

[英]Getting "exec user process caused "no such file or directory"" error when trying to run Docker image

I'm trying to run a simple image that executes .sh file but I got this error.我正在尝试运行一个执行 .sh 文件的简单图像,但出现此错误。

standard_init_linux.go:185: exec user process caused "no such file or directory" standard_init_linux.go:185: exec 用户进程导致“没有这样的文件或目录”

Here is my Dockerfile这是我的 Dockerfile

FROM python:2
ADD . .
CMD ["./test.sh"]

test.sh : test.sh

#!/bin/bash
echo "test"

I'm running Docker in Windows 10 and I have checked '/bin/bash' is existed in the container.我在 Windows 10 中运行 Docker,我检查了容器中是否存在“/bin/bash”。

Why I got this error?为什么我收到这个错误?

I have faced the exact same issue when I tried to create a Linux container image with Docker on windows 10. When you copy the file from windows to docker image, the file format is that of dos.当我尝试在 Windows 10 上使用 Docker 创建 Linux 容器映像时,我遇到了完全相同的问题。当您将文件从 Windows 复制到 docker 映像时,文件格式是 dos 格式。 You may need to run dos2unix utility on all the files before copying them inside docker image.您可能需要在所有文件上运行dos2unix实用程序,然后再将它们复制到 docker 映像中。

To make things clear, I would share my experience.为了说清楚,我会分享我的经验。 When I checked out my project source code using git on windows and tried to create a linux docker container by building the image locally, I got the exact same error message.当我在 Windows 上使用 git 检查我的项目源代码并尝试通过在本地构建映像来创建 linux docker 容器时,我收到了完全相同的错误消息。 This happened because I created my git project on Linux but this time, I checked out on windows.发生这种情况是因为我在 Linux 上创建了我的 git 项目,但这一次,我在 Windows 上进行了检查。 My default git global configuration on windows was checkout Windows-style commit Unix-style, ie Git will convert LF to CRLF when checking out text files.我在 Windows 上的默认 git 全局配置是 checkout Windows-style commit Unix-style,即 Git 在检出文本文件时会将 LF 转换为 CRLF。 When committing text files, CRLF will be converted to LF.提交文本文件时,CRLF 将转换为 LF。 For cross-platform projects, this is the recommended setting on Windows ("core.autocrlf" is set to "true")对于跨平台项目,这是 Windows 上的推荐设置(“core.autocrlf”设置为“true”)

In order to resolve this, I changed my windows' git global config as I wanted to checkout Unix-style commit Unix-style.( How to change line-ending settings )为了解决这个问题,我改变了我的 windows 的 git 全局配置,因为我想签出 Unix 风格的提交 Unix 风格。( 如何更改行尾设置

git config --global autocrlf input

After this, I checked out my project again and created a fresh local image that ran perfectly.在此之后,我再次检查了我的项目并创建了一个运行完美的新本地映像。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行 Docker 图像 ros:k.netic 时出现问题(standard_init_linux.go:211:exec 用户进程导致“exec 格式错误”) - Problem when running Docker image ros:kinetic (standard_init_linux.go:211: exec user process caused "exec format error") Docker standard_init_linux.go:228: exec 用户进程导致:没有这样的文件或目录 - Docker standard_init_linux.go:228: exec user process caused: no such file or directory Docker - standard_init_linux.go:211:执行用户进程导致“执行格式错误”覆盆子 - Docker - standard_init_linux.go:211: exec user process caused “exec format error” raspberry Docker:standard_init_linux.go:211:exec 用户进程导致“exec 格式错误” - Docker: standard_init_linux.go:211: exec user process caused "exec format error" 问题:standard_init_linux.go:228:导致执行用户进程:没有这样的文件或目录 - Issue with : standard_init_linux.go:228: exec user process caused: no such file or directory 树莓派 docker 错误:standard_init_linux.go:178:exec 用户进程导致“exec 格式错误” - Raspberry-pi docker error: standard_init_linux.go:178: exec user process caused “exec format error” Docker 映像中的生锈:执行没有这样的文件或目录 - Rust in Docker image: exec no such file or directory 尝试构建 hbase docker 映像时为 java 安装获取“没有此类文件或目录” - Getting "No such file or directory" for java installation when trying to build a hbase docker image Docker buildx 与 Apple M1 Silicon 上的节点应用程序 - standard_init_linux.go:211:执行用户进程导致“执行格式错误” - Docker buildx with node app on Apple M1 Silicon - standard_init_linux.go:211: exec user process caused "exec format error 错误:standard_init_linux.go:228:导致执行用户进程:执行格式错误 - Error : standard_init_linux.go:228: exec user process caused: exec format error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM