Reputation: 63
I'm trying to run a simple image that executes .sh file but I got this error.
standard_init_linux.go:185: exec user process caused "no such file or directory"
Here is my Dockerfile
FROM python:2
ADD . .
CMD ["./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.
Why I got this error?
Upvotes: 1
Views: 2233
Reputation: 2234
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. You may need to run dos2unix utility on all the files before copying them inside docker image.
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. This happened because I created my git project on Linux but this time, I checked out on windows. My default git global configuration on windows was checkout Windows-style commit Unix-style, i.e. Git will convert LF to CRLF when checking out text files. When committing text files, CRLF will be converted to LF. For cross-platform projects, this is the recommended setting on Windows ("core.autocrlf" is set to "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)
git config --global autocrlf input
After this, I checked out my project again and created a fresh local image that ran perfectly.
Upvotes: 2