tl;dr: Docker error as soon as I have more than 1 line in my Dockerfile.
Version 1 of my Dockerfile:
FROM hello-world:nanoserver-1809
Build command:
docker build -t hello-world:windows .
Output:
Sending build context to Docker daemon 4.096kB
Step 1/1 : FROM hello-world:nanoserver-1809
---> bb8a46951ebd
Successfully built bb8a46951ebd
Successfully tagged hello-world:windows
--> This is OK!
Version 2 of my Dockerfile:
FROM hello-world:nanoserver-1809
WORKDIR tmp
ADD https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/gs952w64.exe .
RUN gs952w64.exe /S
Build command:
docker build -t hello-world:windows .
Output:
Sending build context to Docker daemon 4.096kB
Error response from daemon: Dockerfile parse error line 1: FROM requires either one or three arguments
--> This is unexpected!
Honestly, I'm baffled. What's wrong here? How do I write simple dockerfiles that don't produce unexpected errors?
Solution found thanks to the comment of David Maze.
Turns out I had Mac line endings (CR), which is ridiculous, because I don't even own a Mac.
Neither dos2unix nor unix2dos wanted to fix the line ending problem. So in the end I opened the file in nano, and saved it with DOS (CRLF) line endings using Ctrl+O, Alt+D. With this, my Dockerfile worked.
Then I used dos2unix to convert the line endings from CRLF to LF, and that version also works.
To summarize:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With