Docker Community Forums

Share and learn in the Docker community.

Trying to get get an arm64 based docker image to run on x86 host?

Hello everyone,

I am using docker to create an arm64 images to run on my x86 machine so I can compile arm64 programs to run on my rpi and on my android phone using proot containers.

I am using this website for a guide: Running and Building ARM Docker Containers on x86 | Stereolabs

So I am using a Fedora 33 host and have installed qemu and the other related packages.

When I run :

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

I get this output:

SI  localhost  ~  docker run --rm --privileged multiarch/qemu-user-static --reset -p yes Setting /usr/bin/qemu-alpha-static as binfmt interpreter for alpha Setting /usr/bin/qemu-arm-static as binfmt interpreter for arm Setting /usr/bin/qemu-armeb-static as binfmt interpreter for armeb Setting /usr/bin/qemu-sparc-static as binfmt interpreter for sparc Setting /usr/bin/qemu-sparc32plus-static as binfmt interpreter for sparc32plus Setting /usr/bin/qemu-sparc64-static as binfmt interpreter for sparc64 Setting /usr/bin/qemu-ppc-static as binfmt interpreter for ppc Setting /usr/bin/qemu-ppc64-static as binfmt interpreter for ppc64 Setting /usr/bin/qemu-ppc64le-static as binfmt interpreter for ppc64le Setting /usr/bin/qemu-m68k-static as binfmt interpreter for m68k Setting /usr/bin/qemu-mips-static as binfmt interpreter for mips Setting /usr/bin/qemu-mipsel-static as binfmt interpreter for mipsel Setting /usr/bin/qemu-mipsn32-static as binfmt interpreter for mipsn32 Setting /usr/bin/qemu-mipsn32el-static as binfmt interpreter for mipsn32el Setting /usr/bin/qemu-mips64-static as binfmt interpreter for mips64 Setting /usr/bin/qemu-mips64el-static as binfmt interpreter for mips64el Setting /usr/bin/qemu-sh4-static as binfmt interpreter for sh4 Setting /usr/bin/qemu-sh4eb-static as binfmt interpreter for sh4eb Setting /usr/bin/qemu-s390x-static as binfmt interpreter for s390x Setting /usr/bin/qemu-aarch64-static as binfmt interpreter for aarch64 Setting /usr/bin/qemu-aarch64_be-static as binfmt interpreter for aarch64_be Setting /usr/bin/qemu-hppa-static as binfmt interpreter for hppa Setting /usr/bin/qemu-riscv32-static as binfmt interpreter for riscv32 Setting /usr/bin/qemu-riscv64-static as binfmt interpreter for riscv64 Setting /usr/bin/qemu-xtensa-static as binfmt interpreter for xtensa Setting /usr/bin/qemu-xtensaeb-static as binfmt interpreter for xtensaeb Setting /usr/bin/qemu-microblaze-static as binfmt interpreter for microblaze Setting /usr/bin/qemu-microblazeel-static as binfmt interpreter for microblazeel Setting /usr/bin/qemu-or1k-static as binfmt interpreter for or1k

Then when I run:

docker run --rm -t arm64v8/ubuntu uname -m

I should get

aarch64

as an output but instead get

SI  localhost  ~  docker run --rm -t arm64v8/ubuntu uname -m `` SI  localhost  ~ 

this. What am I doing wrong? I don’t see the uname output?

Thanks

Build ARM Images on x86 Hosts

  1. Install QEMU
    If you have a Debian or Ubuntu system, you can install qemu and binfmt module with apt-get command.
    apt-get update && apt-get install -y --no-install-recommends qemu-user-static binfmt-support
    update-binfmts --enable qemu-arm
    update-binfmts --display qemu-arm

Or you can install qemu from Github source code.
git clone git://git.qemu.org/qemu.git
cd qemu
./configure --target-list=arm-linux-user --static
make

Please make sure that the qemu-arm-static binary is under /usr/bin/ directory of your system. If not, copy it from post-compiled qemu file.
Register qemu-arm with binfmt module.
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
echo ‘:arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:’ > /proc/sys/fs/binfmt_misc/register

  1. Copy qemu-arm-static to Your Working Directory
    You need a copy of qemu-arm-static in your working directory for further modification.
    cp /usr/bin/qemu-arm-static /your/working/dir

  2. Modify the Dockerfile
    Add this line of code, which makes a copy of qemu-arm-static binary to your docker image, below the “FROM” instruction in you Dockerfile.
    COPY qemu-arm-static /usr/bin/qemu-arm-static

  3. Build Docker Image with the Modified Dockerfile
    Now build your docker image with the modified Dockerfile.
    docker build -t your-image-name .