Fix *standard_init_linux.go:XXX: exec user process caused “no such file or directory”* Error

TL;DR: Use dos2unix

While switching from Ubuntu to Alpine images, I’ve encountered the fillowing error:

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

Quite unfortunate, because the script stayed in the same spot and only the image changed. After reading a bunch, I figured that it’s the fact that I’m editing on Windows and Alpine doesn’t seem to interpret #/bin/sh properly – adding a ^M :). The solution is to either fix the script locally or to format it as part of the docker build process. I chose the latter as the former depends on the developer.

Since dos2unix is not part of Alpine, one needs to install it. At the time of writing, the package is on the edge branch. Therefore, the install sequence would be:

We copy the script and post-process it:

At this point, the script is primed for execution and the error is practically fixed.


In the quest to reduce the docker image, the actual sequence is:

This will ensure dos2unix is removed at the end of processing.


A little experiment: If you find this post and ad below useful, please check the ad out :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top