-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Arg blank string defaulting overrides docker default build arg values #3533
Comments
I just realized I've been testing this against 1.6.2 by mistake. Apologies if it does not apply anymore. I will retest with 1.7.1 as soon as possible. |
The issue persists in 1.7.1. Moreover, both 1.6.2 and 1.7.1 produces "None" as the arg value if the arg is specified as
or
|
Thanks! And sure, I'll try. Consider a Dockerfile which has:
That is, it has a parameterized build argument "x", which will default to 1 if no --build-arg x=... is given However, if we wish to parameterize our compose file in a similar fashion as in the examples above, we are left with no option. As soon as we specify a build arg in the compose file, we cannot recover the default from the Dockerfile at build time, as an unset var in - x=$x will always at least be the empty string and never count as not setting --build-arg x=... This in turn seems to make it impossible to disambiguate a build arg with the same name (from two or more separate Dockerfiles, or even the same, built with different values) in a composition if we ever want one of the services to rely on the default value specified in the Dockerfile. |
Oh, that makes a lot of sense - thanks for taking the time to clarify. |
Or rather "if this environment variable is undefined, use the default value from the Dockerfile" Otherwise parameterization would still fail. :-) Thanks! |
Even if the notation is new and unique?
|
I believe we fixed this bug in master, so the fix will be in 1.8.0. I think using the "no value" style is the correct way to handle this: |
…ument values being overridden by blank strings (docker/compose#3533)
If several services in a composition contain the same build arg, it's very hard (I haven't found a good method yet) to disambiguate it while retaining the ability to have default build args in a Dockerfile.
The obvious way to disambiguate build args would be to prepend the service name:
However, if $a_x or $b_x are unset, they will be defaulted to empty strings with the warning:
Now, they will be passed to docker build as empty strings, circumventing any default arg in the Dockerfile.
This seems to me to be a very surprising and not docker-like way of handling it. A less surprising (and more featureful) method would be to not pass unset build args at all.
The text was updated successfully, but these errors were encountered: