Skip to content
/

‘docker run’ throws “exec user process” errors

When recently creating a Linux Docker image using Docker for Windows, I ran into a couple of vague errors. Searching online for the error messages, there weren’t any solutions. But luckily some suggestions put me on the right track.
In this post I describe the solutions I found. Hopefully preventing you wasting time on the same issues.

The Dockerfile

My Dockerfile is based on the Azure App Service WordPress 0.3 Dockerfile.
In relation to the errors I encountered, the most important part in this file is the that is declared:

ENTRYPOINT ["entrypoint.sh"]

After adding the entrypoint.sh file to the directory where I build my image, I ran the docker build command:
docker build --tag blog/demo:v1 .

Once the build was completed, I launched the image locally:
docker run blog/demo:v1

But that wasn’t as straight forward as expected.

Linefeeds matter: no such file or directory

First, I got the following response:

standard_init_linux.go:195: exec user process caused "no such file or directory"

This is quite a generic error message and can describe a lot of files or directories that are part of the process of building and running Docker images and containers. My first impression was that the image building was not working correctly. But after a lot of rebuilds, the error didn’t go away.
I finally found the real source of the issue: changing the linefeeds in the entrypoint.sh file from CRLF to LF, somehow made the file discoverable.

Visual Studio Code showing CRLF in the status bar

Visual Studio Code showing CRLF in the status bar

Changing the linefeed option in Visual Studio Code

Changing the linefeed option

However, I still couldn’t run my container, only the error message had changed...

Encoding matters: exec format error

Executing the docker run command again, the output was now a different error:

standard_init_linux.go:195: exec user process caused "exec format error"

The mentioning of format error made me guess that this had something to do with incompatibilities running a Linux image on a Windows OS, or something related to x86 vs. x64. Many articles you’ll find searching on the error message are pointing in that direction.
Luckily, I overheard a colleague solving a completely unrelated issue by changing the encoding of his XML file from UTF-8 to ISO-8859-15. I figured to just try that with my file... solving the issue!

Save the file with reencoding dialog in Visual Studio Code

Save the file with reencoding

Select the file encoding dialog in Visual Studio Code

Select the file encoding

Conslusion

When using Docker on Windows and working with Linux containers, make sure the encoding and linefeeds of the files involved are correct, otherwise you are hit with vague error messages that are not helpful at all.

Leave a comment