This post was most recently updated on September 27th, 2022.3 min read.
Another one in the series of “random things that break when you try to run Docker on Windows”!
I was just minding my own business, trying to run an Azure IoT Edge custom module – a Docker container, really – locally, when suddenly everything broke and one of my Docker containers wouldn’t run anymore, which broke the rest of my stuff pretty badly. Instead, it failed with a cryptic and surprising error “exec user process caused: no such file or directory”.
This article explains how to fix that issue. So, let’s take a closer look, shall we?
I think this can happen any time you work with Docker containers, but for me, the issue was surfaced with Azure IoT Edge simulator.
In my case, I was building a Docker container to initialize a TimescaleDB database in my local Azure IoT Edge simulator. But whenever my initialization container (DatabaseInitialization) would try and fire, it would fail and throw an error like this:
standard_init_linux.go:228: exec user process caused: no such file or directory
Or like shown below in VSCode:
That is not supposed to happen! There should have been a couple of lines of logging, where that container ran some tricky SQL commands to instantiate a couple of databases in another container. But nope – it just decided to crash instead.
Docker likely doesn’t understand your line breaks because you’re on Windows. Or at least I was, and that was the issue for me.
Your situation might be different, but there’s a fair chance the same fix will work for you as well.
So what IS the fix? Let’s take a closer look!
Solution to “exec user process caused: no such file or directory”
This simple how-to is going to show how to fix the issue using Visual Studio Code, but you can do the same thing in different word processors if need be.
Time needed: 6 minutes
How to fix “exec user process caused: no such file or directory” in Docker on Windows?
- Open your dockerfile
Whip your dockerfile open in your text editor of choice. For me, that’s going to be Visual Studio Code, in which I will be showing you how to perform the required steps to (hopefully) fix the issue!
- Find your line-break configuration
Line-break configuration is going to be hidden all the way at the bottom right of your Visual Studio Code window – something like shown below:
Other text editors should have the configuration as well, but it might only be available during saving the file, for example.
- Change CRLF -> LF
“Fixing” your line breaks means changing it to be what Docker expects it to be. Likely LF instead of CRLF.
I mean, you don’t want that Carrier-Return-Line-Feed, which Windows uses. Instead, just opt for the beautiful Linux-style Line-Feed instead!
Remember to save your changes.
- Run whatever Docker stuff you were trying to run before
You can now run Docker in any way compatible with your workflow :)
In case your workflow would be the same as mine, just rerun your IoT Edge Simulator. Something like the below:
If you got the error from the Azure DevOps pipeline instead, remember to commit your changes and build from the right branch!
- (OPTIONAL?): Change the line break sequence for all files for your container
Not sure if you’ll actually need to do this, but in case you’re running some shell scripts or importing any .sql files, you might need to repeat steps 2-3 for them as well. I mean, I had to – otherwise you’ll get either the same or a similar error.
You might need to experiment a bit to figure out which files are affected, though.
And there you go! You should be good :)
- How to update application settings for (all of your) App Services and Azure Functions on Azure using az cli? - October 24, 2023
- swa emulator throwing “✖ Could not connect to “http://localhost:7071″. Is the server up and running?”? - October 17, 2023
- How to export an App Service Certificate from Azure? - October 10, 2023