Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile: improve error-messages for invalid flags or flags without required value #5368

Open
thaJeztah opened this issue Sep 30, 2024 · 1 comment

Comments

@thaJeztah
Copy link
Member

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)

@tonistiigi
Copy link
Member

@thaJeztah Was this supposed to be closed by #5369?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants