Skip to content

Using TARGETARCH before the FROM line does not work #574

Description

@ndepal

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions