Noticed these errors while writing an example;
Example 1: invalid option / flag;
Dockerfile:2
--------------------
1 | FROM alpine
2 | >>> COPY --nosuchflag . .
3 |
--------------------
ERROR: failed to solve: dockerfile parse error on line 2: unknown flag: nosuchflag
Example 2: flag with missing value;
Dockerfile:4
--------------------
2 | FROM alpine
3 | WORKDIR /test
4 | >>> COPY --exclude /.git . .
5 |
--------------------
ERROR: failed to solve: dockerfile parse error on line 4: missing a value on flag: exclude
I wonder if we could improve that error;
- refer to the flag as
--exclude instead of exclude
- perhaps print the expected format (
--exclude=<path>)
- suggest a possible fix, e.g. for this example,
did you mean --exclude=/.git ?
Last one is always tricky, because COPY allows more than 2 arguments, so COPY /.git . . is technically correct (although /.git overlaps with ., so could be some warning on its own)