My Dockerfile works on x86 machine, but fails on the machine with arm64
architecture; specifically on a1.2xlarge
(an aws EC2-instance
).
Error on running docker compose up -d
#0 0.462 exec /bin/sh: exec format error
------
failed to solve: executor failed running [/bin/sh -c apt-get update]: exit code: 1
Dockerfile looks like this
FROM phusion/passenger-ruby27
ENV HOME /root
RUN apt-get update
docker -v
Docker version 20.10.17, build 100c701
uname -a
Linux Ubuntu SMP Thu Jun 9 13:06:11 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
lsb_release -a
Ubuntu 20.04.4 LTS
2
Answers
phusion/passenger-ruby27 repository separates the arm64-based images via tags (as of Nov-2022).
I.e. 2.3.1 and 2.3.1-arm64
Assuming that you want to build an arm64 image on your arm64 instance, a simple way to resolve this is to pass the tag as a build argument.
Dockerfile:
Build examples:
You might need to either user
docker buildx
or install QEMU or possibly both.There are various methods to setting up QEMU, for example when running in a GitHub pipelines you can use the GitHub action setup-qemu-action
Assuming that you are on an ubuntu based system, first check what platforms your docker driver supports.
now install qemu.
Now we have added support for arm64 architecture.