Cross-platform windows images don't load
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4.5k
- Forks
- 682
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 29
Description
docker buildx doesn't seem to be working for building windows platform images from linux.
Building from an amd64/linux machine, the following commands all complete successfully (although the two linux commands have a couple seconds in the "importing to docker" step, where in the windows command it's zero seconds).
$ docker buildx build --platform linux/arm64 --build-arg TARGETPLATFORM=linux/arm64 --build-arg ARCH=arm64 --build-arg BASE_IMAGE=debian --build-arg BINARY=multiarch-test -t local_ws_prefix/multiarch-test-arm64-linux:test . --load
$ docker buildx build --platform linux/amd64 --build-arg TARGETPLATFORM=linux/amd64 --build-arg ARCH=amd64 --build-arg BASE_IMAGE=debian --build-arg BINARY=multiarch-test -t local_ws_prefix/multiarch-test-amd64-linux:test . --load
$ docker buildx build --platform windows/amd64 --build-arg TARGETPLATFORM=windows/amd64 --build-arg ARCH=amd64 --build-arg BASE_IMAGE=mcr.microsoft.com/windows/servercore:10.0.19042.685 --build-arg BINARY=multiarch-test.exe -t local_ws_prefix/multiarch-test-amd64-windows:test . --load
But only the two linux images appear:
$ docker images | grep local_ws_prefix
local_ws_prefix/multiarch-test-amd64-linux test 5631c29885e7 8 minutes ago 126MB
local_ws_prefix/multiarch-test-arm64-linux test eebed83554f0 11 minutes ago 120MB
I expected either the windows command to produce an image, or to not complete successfully.
Here's the dockerfile and a main.go; drop them both into a directory and run go mod init multiarch-test
Dockerfile
ARG TARGETPLATFORM
ARG BINARY
ARG BASE_IMAGE
FROM --platform=linux/amd64 golang:1.16 AS builder
WORKDIR /code
ADD . /code/
RUN cd /code/ && mkdir -p bin && GOOS=$(echo $TARGETPLATFORM | cut -f1 -d '/') GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') go build -o bin/$BINARY .
FROM ${BASE_IMAGE}
LABEL description="PD CSI driver"
COPY --from=builder /code/bin/$BINARY /$BINARY
main.go
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println(runtime.GOOS)
}
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
Reproduce the three docker buildx build commands using the provided Dockerfile and main.go, then compare the Windows result with docker images. Start by tracing the --load behavior for the windows/amd64 build; done means the command either loads a usable Windows image or reports the failure instead of completing silently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- build-system, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100