title: Why is a Dockerfile for an ARM-based Go app dropping "linux_arm" from runtime path?
body: <p>I am using a Dockerfile as follows to create an image using <code>docker build</code> on a Raspberry Pi, which is ARM-based. But it is failing at the <code>COPY --from=builder</code> step because it cannot find the path &quot;/go/bin/linux_arm/example-experiment&quot;, and a couple of debug &quot;ls&quot; commands at the end of the &quot;builder&quot; stage show that the actual path created in that stage was &quot;/go/bin/example-experiment (i.e. missing the &quot;linux_arm&quot; directory level) :</p>
  <pre><code>FROM golang:latest AS builder
  
  ENV GOPATH $GOPATH:/go/src/example-experiment
  ENV GOOS linux
  ENV GOARCH arm
  ENV GOARM 7
  
  RUN apt-get update &amp;&amp; apt-get install git
  
  ADD . /go/src/example-experiment/
  WORKDIR /go/src/example-experiment
  
  RUN go get -v ./...
  
  RUN go install
                                                                                                                                                                              
  FROM scratch
  
  # Copy the static executable.
  COPY --from=builder /go/bin/linux_arm/example-experiment /go/bin/linux_arm/example-experiment
  
  # Run the application's executable binary.
  ENTRYPOINT [&quot;/go/bin/linux_arm/example-experiment&quot;]
  </code></pre>
  <p>I tried replacing <code>RUN go install</code> by <code>RUN go build</code> but the same thing happened.</p>
  <p>Possibly this is more about Go than Docker. But a colleague running a build with the same Dockerfile finds it completes with no errors, and presumably their base image uses the same version of Go.</p>
  <p>The actual error is as follows :</p>
  <pre><code>Step 19/20 : COPY --from=builder /go/bin/linux_arm/example-experiment /go/bin/linux_arm/example-experiment
  COPY failed: stat /var/lib/docker/overlay2/36eef7ea57e69d51c9f00dc151fde8c0e7cd38a2ca3e51505c153594f57db5ba/merged/go/bin/linux_arm/example-experiment: no such file or directory
  </code></pre>
  <p>I thought Go was supposed to create a runtime path /go/bin/$GOOS_$GOARCH/... which in this case is /go/bin/linux_arm/...</p>