title: how to set architecture when building multi-arch Docker image?
body: <p>Let's say I have an app <code>foo</code> built for many different arches (e.g, <code>foo-arm64</code>, <code>foo-amd64</code>, etc).  I would like to make very small Docker images like so:</p>
  
  <pre><code>FROM scratch
  
  ARG ARCH
  ADD foo-$ARCH /bin/foo
  
  ENTRYPOINT [ "/bin/foo" ]
  </code></pre>
  
  <p>However, when I build an image:</p>
  
  <pre><code>docker build -t foo:arm64 --platform linux/arm64 --build-arg ARCH=arm64 .
  </code></pre>
  
  <p>the architecture isn't correct:</p>
  
  <pre><code>docker inspect foo:arm64 | grep Arch
          "Architecture": "amd64",              # should be arm64??
  
  </code></pre>
  
  <p>The image arch seems to always come from the host.  How can I build a Docker image with the right architecture when that differs from the host?  How do the official Docker images do this?</p>