I have a Dockerfile where I would like to use the TARGETARCH that is set by buildx in my FROM line:
ARG TARGETARCH
FROM gcr.io/my-container-registry/my-container-${TARGETARCH}
...
(I'm aware that if I built my-container for multiple platforms in the same docker buildx build --platform x,y command, I would not have to use different tags for different platforms. But I don't want to do that since I usually want to build the images for each architecture on machines with that architecture.)
Expected:
Running docker buildx build --platform arm64 ... should result in FROM gcr.io/my-container-registry/my-container-arm64
What actually happens:
failed to parse stage name "gcr.io/my-container-registry/my-container-": invalid reference format
Using ARG TARGETARCH after the FROM line works as expected (although I did also run into #510, expecting it to work as @MarcelWaldvogel did).
Is there a way to get this to work? Or is this the intended behavior?
I have a Dockerfile where I would like to use the
TARGETARCHthat is set by buildx in myFROMline:(I'm aware that if I built
my-containerfor multiple platforms in the samedocker buildx build --platform x,ycommand, I would not have to use different tags for different platforms. But I don't want to do that since I usually want to build the images for each architecture on machines with that architecture.)Expected:
Running
docker buildx build --platform arm64 ...should result inFROM gcr.io/my-container-registry/my-container-arm64What actually happens:
failed to parse stage name "gcr.io/my-container-registry/my-container-": invalid reference formatUsing
ARG TARGETARCHafter theFROMline works as expected (although I did also run into #510, expecting it to work as @MarcelWaldvogel did).Is there a way to get this to work? Or is this the intended behavior?