Lowercase error when using automatic platform args in stage names
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4.5k
- Forks
- 682
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 29
Description
Contributing guidelines
- I've read the contributing guidelines and wholeheartedly agree
I've found a bug and checked that ...
- ... the documentation does not mention anything about my problem
- ... there are no open or closed issues that are related to my problem
Description
Using TARGETARCH or other automatic platform args in the global scope in a stage name will result in an error due to it not being lowercase
Expected behaviour
${TARGETARCH} should be resolved to arm64 or amd64 resulting in a valid lowercase stage. The build should succeed and copy from the adequate stage, given behavior changes between both archs (basically if/else in dockerfile)
Actual behaviour
ERROR: failed to solve: failed to parse stage name "foo-${TARGETARCH}": invalid reference format: repository name must be lowercase
Buildx version
github.com/docker/buildx v0.10.4 c513d34
Builders list
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
multiarch docker-container
multiarch0 unix:///var/run/docker.sock inactive linux/arm64*, linux/amd64*
default * docker
default default running 23.0.6 linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
Configuration
# syntax=docker/dockerfile:1
ARG BASE=ubuntu:20.04
FROM ${BASE} AS test-arm64
RUN echo "I am arm64" > /opt/who
FROM ${BASE} AS test-amd64
RUN echo "I am amd64" > /opt/who
FROM ${BASE} AS final
ARG TARGETARCH
COPY --from=test-${TARGETARCH} /opt/who /opt/who
RUN cat /opt/who
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported configuration from the Dockerfile in the issue with Buildx v0.10.4 or a current version, focusing on the FROM aliases and COPY --from stage reference. Trace the stage-name parsing and automatic platform-argument handling to determine where lowercase validation occurs. Done means the sample build succeeds and selects the architecture-specific stage for both arm64 and amd64.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, dockerfile, go
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100