Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"dockerfile parse error line 1 from requires either one or three arguments" but I have only 1 argument

tl;dr: Docker error as soon as I have more than 1 line in my Dockerfile.

  • Dev environment: Ubuntu 20.04 LTS in WSL (Bash)
  • Build environment: Windows Server 2019 (PowerShell)

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?

like image 699
Amedee Van Gasse Avatar asked Oct 22 '25 18:10

Amedee Van Gasse


1 Answers

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:

  • CR line terminators (Mac): doesn't work
  • LF line terminators (Linux): works
  • CRLF line terminators (DOS): works
like image 150
Amedee Van Gasse Avatar answered Oct 25 '25 12:10

Amedee Van Gasse