The way I've been able to reproduce this error is to create a Dockerfile that only contains a comment:
$ echo '#' >df.comment
$ docker build -f df.comment .
[+] Building 0.1s (2/2) FINISHED
=> [internal] load build definition from df.comment 0.0s
=> => transferring dockerfile: 45B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
failed to solve with frontend dockerfile.v0: failed to create LLB definition: file with no instructions
Note that an empty image, without an entrypoint or cmd, will still build, so trying to fix that with those lines is going to send you the wrong way:
$ more df.scratch
FROM scratch
LABEL image=scratch
$ docker build -f df.scratch .
[+] Building 0.3s (3/3) FINISHED
=> [internal] load build definition from df.scratch 0.0s
=> => transferring dockerfile: 76B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> exporting to image 0.0s
=> => writing image sha256:874d031dd4b7103a9f4159a2bc82c7d21e1885aa477150105d482b3e0462aa7e 0.0s
As for why your file isn't working, it's almost certainly something to do with the encoding of the file. From the CLI rather than the editor, try cat Dockerfile
and you should see the file contents, with steps like FROM
at the beginning of the lines. If the file appears to be corrupt or missing line feeds, then it's not saved in the correct format. Typically you would use utf-8, ascii should also work, with linefeeds set to the Linux format (LF, not CR-LF).