-
Notifications
You must be signed in to change notification settings - Fork 481
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
Default value on TARGETPLATFORM
always overrides
#510
Comments
For the builtin args, default value is set if none is set by the user. For your use case it makes sense to overwrite the user's default value but for some others that want to fix |
For the user it is not obvious that (a) As I take your response as "WONTFIX: works as designed", how about changing the documentation to add the following (as there are no footnotes in Markdown, something along the following lines should be placed right before "High-level build options"): Backward compatibilitySometimes, backward compatibility of the build process to ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64} |
Yes, docs can always be improved (via PR). If you look at the current docs https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope it is defined that these parameters are defined in the global scope and global scope working like this is already documented. We don't want to spend that much time describing what happens on other builders that users shouldn't care about but just encourage them to update. But adding a line reminding people that |
I tried to shorten the explanation as much as possible. I hope it meets your expectations. |
See docker/buildx#510 Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
Fixes opiproject#163 See docker/buildx#510 Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
Fixes opiproject#163 See docker/buildx#510 Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
Fixes opiproject#163 See docker/buildx#510 Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
Fixes opiproject#163 See docker/buildx#510 Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
Fixes opiproject#163 See docker/buildx#510 Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
Fixes opiproject#163 See docker/buildx#510 Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
Fixes opiproject#163 See docker/buildx#510 Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
This patch contains workaround to have the same Dockerfile for `docker build` and `docker buildx` described at [1]. [1] docker/buildx#510 Signed-off-by: Ivan Kolodiazhnyi <ikolodiazhny@nvidia.com>
This patch contains workaround to have the same Dockerfile for `docker build` and `docker buildx` described at [1]. [1] docker/buildx#510 Signed-off-by: Ivan Kolodiazhnyi <ikolodiazhny@nvidia.com>
I've spent hours trying the solve an issue caused by this. When I set a default value on an ARG, I expect it to be overriden by If this is not fixable please add a note to the documentation so others can avoid falling the same trap. |
When you set default value on an ARG, you can expect it to be overridden by
For clarity, "-linux/amd64" in that Dockerfile never gets called or has any impact on buildkit-based builder, no matter what configuration was passed to the build. |
Sorry, I forgot to mention. I am talking specifically about For example, if there is default value set on FROM debian:buster-slim
ARG TARGETARCH=amd64
RUN echo $TARGETARCH; exit 1 $ docker build --platform linux/arm64 .
...
> [2/2] RUN echo amd64; exit 1: If I remove the default value, it works as expected. FROM debian:buster-slim
ARG TARGETARCH
RUN echo $TARGETARCH; exit 1 $ docker build --platform linux/arm64 .
...
> [2/2] RUN echo arm64; exit 1: |
What I want to achieve
I have a project that I want to be able to build both with
docker build
(for compatibility) anddocker buildx --platform
and which requiresTARGETPLATFORM
to make a difference in the build process. AsTARGETPLATFORM
is not set bydocker build
, the default value option toARG
seemed the right choice.What I expect
Given the following
Dockerfile
,I expect
docker build .
on all architectures to outputlinux/amd64
(the legacy compatibility case).When running
docker buildx --builder docker-multiarch --platform linux/386 .
, the output should belinux/386
.What I get
On platform
linux/amd64
,docker buildx --builder docker-multiarch --platform linux/386 .
, outputslinux/amd64
instead oflinux/386
.Removing the default value solves this:
docker buildx --builder docker-multiarch --platform linux/386 .
results inlinux/386
with Dockerfile:However,
docker build .
results in an empty/undefinedTARGETPLATFORM
.(For
ARG
s set with--build-arg
on the command line, defaults behave as expected.)System setup
Workaround
The following Dockerfile results in the expected behavior:
However, this (a) defeats the purpose of the default value and (b) causes endless debugging sessions, as it violates the documentation of
ARG
andTARGETPLATFORM
.The text was updated successfully, but these errors were encountered: