-
Notifications
You must be signed in to change notification settings - Fork 24
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
RUN contains undefined ARG or ENV variable for a very defined ARG variable #52
Comments
Can you please try with |
Similar example with
Dockerlint 0.3.9 |
I've just run into this issue myself. Wanted to post a solution here in case anyone else comes across this particular issue
however, if you do the following, the error goes away ARG foo=${foo:-""} The interpolated command is a bash parameter substitution construct that says: use $foo if it exists or default to empty. The dash before "" is needed. https://tldp.org/LDP/abs/html/parameter-substitution.html explains what is going on in greater detail with examples In any event, I believe the crux of the issue is to set a default value on the foo ARG to stop the error from showing up. |
As shown in the title, the problem is that the ARG is already defined, but that the error thinks it is not. My example is probably the most on-the-nose case:
Certainly a "very defined ARG variable," not that the linter thinks so.
I wish it were so simple. But since I also have the error, and I am explicitly defining the ARG... this cannot be the case. At the very least, the problem is more complex. Not even going to touch "why does Bash parameter substitution fix a linter error in a Dockerfile that even presents in the IDE package." I'm glad the solution worked for you, I'm just sad no one knows how to fix the underlying issue yet, or what it is. |
Very simple reproduction case: FROM python:3.9-slim
ARG sha
ENV CURRENT_COMMIT_SHA=$sha @rnagy can this get a bug label please? |
Issue details
This seems different from #47 and #49
Steps to reproduce/test case
This should not raise any issues:
It raises:
Affected version(s)
0.3.1
and0.3.9
are affected.The text was updated successfully, but these errors were encountered: