I'm trying to use an x86 Linux host machine to build an arm64 Linux docker image.
Despite specifying --platform linux/arm64
, I still get errors that suggest I'm not.
Dockerfile:
FROM ubuntu:20.04
SHELL ["/bin/bash", "-c"]
RUN echo 'Hello world'
Command:
docker build --progress plain --platform linux/arm64 -f test.Dockerfile . --no-cache
Output:
Sending build context to Docker daemon 989.2kB
Step 1/2 : FROM ubuntu:20.04
---> d25e19480966
Step 2/2 : RUN echo 'Hello world'
---> [Warning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
---> Running in f6c3dc9c965f
standard_init_linux.go:228: exec user process caused: exec format error
The command '/bin/sh -c echo 'Hello world'' returned a non-zero code: 1
Why does docker tell me "and no specific platform was requested" even though I do specify one? Oddly enough, this command works on my M1 Mac regardless of whether I specify linux/amd64 or linux/arm64 as the target platform. I would have expected a Linux-to-Linux build to run more smoothly. What am I missing?
Additional details:
Host machine is an EC2 instance running the Amazon Linux 2 AIM (amzn2-ami-kernel-5.10-hvm-2.0.20220606.1-x86_64-gp2)
$ docker --version
Docker version 20.10.13, build a224086
$ uname -m
x86_64
I installed qemu manually via
sudo yum install qemu-kvm -y