When recently creating a Linux Docker image using Docker Desktop 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 ENTRYPOINT that is declared:
After adding the entrypoint.sh
file to the directory where I build my image, I ran the docker build command:
Once the build was completed, I launched the image locally:
But that was not as straight forward as expected.
Linefeed matter: no such file or directory
First, I got the following response:
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 linefeed in the entrypoint.sh
file from CRLF
to LF
, somehow made the file discoverable.
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:
The mentioning of a “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!
Conclusion
When using Docker on Windows and working with Linux containers, make sure the encoding and linefeed of the files involved are correct, otherwise you are hit with vague error messages that are not helpful at all.