Save yourself some time

[Python Flask service in Docker]

Fix “exec user process caused „no such file or directory“” in Docker

…and a few other tiny things such as "standard_init_linux.go:219: exec user process caused: exec format error"

So, it was just a casual Sunday evening and in out house that means fiddling around with Python and Docker and…. you get the picture, we’re no ordinary family.

To put things in context I was doing this Flask “backend service” that was supposed to simulate “n” number of simulations of the Monty Hall problem, yielding results back to a subscribed frontend in chunks so that we get some sort of progress. Now, me being a good citizen I wanted to put everything in a Docker container and that’s why I provided a Dockerfile with everything you need. I will eventually put the code on GitHub so that everyone benefits from it, but I wanted to use this post to make a reference for myself so that when I scratch my head next time, I at least have this post as a start with troubleshooting.

I’m one of those people that is a firm believer that the first solution that comes to mind is not the best one. That’s why I bother people around me to challenge my ideas so much. But, still there are sometimes these tiny little things that we know are gonna leave us frustrated and we still go and do them regardless. In other words I was sloppy. Further more I kept running that Dockerfile until I had to stop and think what the hell is it that I’m trying to do here.

Let’s start with the dreaded: "standard_init_linux.go:219: exec user process caused: exec format error standard_init_linux.go:219: exec user process caused: exec format error standard_init_linux.go:219: exec user process caused: exec format error"

Lesson 1:

First of all if you’re gonna put in your docker file, remember that this file is a shell script that will run in your container

RUN chmod +x ./
CMD ["./"]

so go inside and add that


or if you use alpine without bash


in my case the file looks like this:

#!/usr/bin/env sh

service nginx start
uwsgi --ini uwsgi.ini

Lesson 2:

If you’re doing your development in Windows but trying to create a script (regardless how small) that is supposed to run inside a Linux container make sure that

You don’t forget to change the line endings

TehBoyan from 2021

So, go to notepad++ and replace all those CRLFs with LFs that Linux expects.

Also, Git Bash for Windows comes with a tool called dos2unix.exe, so you can use that one if want another alternative


Hope this helps some of you out there!

Happy coding people!