We ran into the following error when creating Docker-based GitHub Actions:
the “standard_init_linux.go:211: exec user process caused „no such file or directory“”
Everything worked locally and the Dockerfile looked good as well. Yet, when pushing the code to the build server (in this case GitHub), building the Docker image failed wit the mentioned error.
The problem: a wrong file format caused by Windows. Let’s fix this!
Fixing the Error using dos2unix
Docker outputs all build steps when creating an image based on a Dockerfile. The “exec user process caused „no such file or directory“” issue occurred when executing a shell script.
The Docker build output looked like this:
…
Status: Downloaded newer image for docker:stable
Step 2/4 : …
Step 3/4 : …
Step 4/4 : …
Successfully built f28971cbf685
Successfully tagged af96b4:b7a96601212a5f0e24b726cd4a1cd6bb
/usr/bin/docker run …
standard_init_linux.go:211: exec user process caused „no such file or directory“
The error message is misleading in terms of a wrong file path or path reference. In our case, the issue occurred due to a Windows-style file ending.
We created the Dockerfile
on a Windows machine. Saving the Dockerfile
used the default Windows file format. This caused the Docker build to fail on a Linux machine.
Fixing the file format: change to UNIX style
What we did to fix is converting the file format to UNIX style using dos2unix
:
dos2unix your-file.sh
The file content looked the same after formatting it to UNIX style. Yet, the build succeeded on the Linux machine 🥳
You can run the dos2unix
command on any Linux system. If you don’t have access to a Linux system, you may use the Git Bash for Windows which comes with a dos2unix.exe
. Your command may then look like this:
dos2unix.exe your-file.sh
Enjoy successful Docker builds on Linux!