Docker - sure, it works great!

How to fix “exec user process caused: no such file or directory” in Docker on Windows?

This post was most recently updated on May 6th, 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”.

So, let’s take a closer look, shall we?

Problem

Table of Contents

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.

What gives?

Reason

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

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: 5 minutes.

How to fix “exec user process caused: no such file or directory” in Docker on Windows?

  1. 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!

  2. 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.

  3. 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!

  4. 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 below:


    If you got the error from the Azure DevOps pipeline instead, remember to commit your changes and build from the right branch!

  5. (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 effected, though.


And there you go! You should be good :)

mm
5 3 votes
Article Rating
Subscribe
Notify of
guest
4 Comments
most voted
newest oldest
Inline Feedbacks
View all comments