skip to Main Content

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


  1. 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:

    ARG BASE_TAG
    FROM phusion/passenger-ruby27:$BASE_TAG
    ENV HOME /root
    RUN apt-get update
    

    Build examples:

    # on arm
    $ docker build --build-arg BASE_TAG=2.3.1-arm64 .
    
    # on amd
    $ docker build --build-arg BASE_TAG=2.3.1 .
    
    Login or Signup to reply.
  2. You might need to either user docker buildx or install QEMU or possibly both.

    QEMU is a free and open-source hypervisor. It emulates the machine’s processor through dynamic binary translation and provides a set of different hardware and device models for the machine, enabling it to run a variety of guest operating systems.

    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.

    docker buildx ls
    NAME/NODE DRIVER/ENDPOINT STATUS  PLATFORMS
    default * docker                  
     default default         running linux/amd64, linux/386
    

    now install qemu.

    sudo apt-get install -y qemu qemu-user-static
    
    docker buildx ls
    NAME/NODE    DRIVER/ENDPOINT             STATUS  PLATFORMS
    default      docker                              
      default    default                     running linux/amd64, linux/386, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/arm/v7, linux/arm/v6
    

    Now we have added support for arm64 architecture.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search