Emulating other CPU architectures in Docker made easy
10K+
This project aims to make cross-compilation, and running programs and images built for a different CPU architecture simple.
Currently the only host architecture supported is amd64 (AKA x86_64), while the architectures that can be emulated are:
arm (AKA arm32v7)aarch64 (AKA arm64v8, arm64)riscv32riscv64There are 3 distinct categories of images below:
:v4.2.0, or :latest.qemu binaries, but can be used to enable emulation for use with your own qemu binary. Tagged with the keyword enable, ex: :v4.2.0-enable, or :enable.v4.2.0-arm, or aarch64.For a complete list of available tags see: r/meedamian/simple-qemu/tags
v4.2.0, v4.2, v4, latestv4.2.0-arm, v4.2-arm, v4-arm, arm (or: arm32v7)v4.2.0-aarch64, v4.2-aarch64, v4-aarch64, aarch64 (or: arm64v8 & arm64)v4.2.0-riscv32, v4.2-riscv32, v4-riscv32, riscv32v4.2.0-riscv64, v4.2-riscv64, v4-riscv64, riscv64v4.2.0-enable, v4.2-enable, v4-enable, enablev4.1.1, v4.1v4.1.1-arm, v4.1-arm (or: -arm32v7)v4.1.1-aarch64, v4.1-aarch64 (or: -arm64v8 & -arm64)v4.1.1-riscv32, v4.1-riscv32v4.1.1-riscv64, v4.1-riscv64v4.1.1-enable, v4.1-enablev4.1.0v4.1.0-arm (or: -arm32v7)v4.1.0-aarch64 (or: -arm64v8 & -arm64)v4.1.0-riscv32v4.1.0-riscv64v4.1.0-enablev4.0.1, v4.0v4.0.1-arm, v4.0-arm (or: -arm32v7)v4.0.1-aarch64, v4.0-aarch64 (or: -arm64v8 & -arm64)v4.0.1-riscv32, v4.0-riscv32v4.0.1-riscv64, v4.0-riscv64v4.0.1-enable, v4.0-enablev4.0.0v4.0.0-arm (or: -arm32v7)v4.0.0-aarch64 (or: -arm64v8 & -arm64)v4.0.0-riscv32v4.0.0-riscv64v4.0.0-enablev3.1.1, v3.1, v3v3.1.1-arm, v3.1-arm, v3-arm (or: -arm32v7)v3.1.1-aarch64, v3.1-aarch64, v3-aarch64 (or: -arm64v8 & -arm64)v3.1.1-riscv32, v3.1-riscv32, v3-riscv32v3.1.1-riscv64, v3.1-riscv64, v3-riscv64v3.1.1-enable, v3.1-enable, v3-enablev3.1.0v3.1.0-arm (or: -arm32v7)v3.1.0-aarch64 (or: -arm64v8 & -arm64)v3.1.0-riscv32v3.1.0-riscv64v3.1.0-enableThe simplest way to run an image built for a different architecture is to run:
# Enable emulation on the host system
docker run --rm --privileged meedamian/simple-qemu -p yes
# Verify it worked
docker run --rm arm32v7/alpine uname -m
If you want to emulate build on your amd64 machine, then:
# Enable emulation on the host system
docker run --rm --privileged meedamian/simple-qemu -p yes
And then in your Dockerfile specify exact base architecture, you want to use:
FROM arm32v7/alpine:3.11
# Everything written here will be run on an emulated architecture
It's that simple :).
Note: To learn what architectures are available for the given base image you can use
docker manifest inspectcommand, for example:$ docker manifest inspect alpine | jq -r '.manifests[].platform | .os + "/" + .architecture + " " + .variant' linux/amd64 linux/arm v6 linux/arm v7 linux/arm64 v8 linux/386 linux/ppc64le linux/s390x
NOTE: For an up-to-date comparison of various
qemuversions see this issue: https://github.com/lncm/docker-bitcoind/issues/9
Emulation can be nightmarishly slow. Here's a (not very scientific) comparison. It uses a random project of mine, and compares it again't baseline (no emulation), and another project I know of (multiarch/qemu-user-static).
qemu version | emulated architecture | time | |
|---|---|---|---|
simple-qemu | qemu-user-static | ||
baseline (amd64) | 1m 56s | ||
| v3.1.1 | arm32v7 | 24m 5s | 22m 19s |
| arm64v8 | 23m 6s | 23m 27s | |
| v4.1.0 | arm32v7 | 24m 36s | 25m 34s |
| arm64v8 | 33m 30s | 32m 23s |
If you discover a bug please report it here. Express gratitude here.
Mail me at [email protected], or on twitter @meeDamian.
MIT @ Damian Mee
Content type
Image
Digest
Size
751 kB
Last updated
almost 6 years ago
docker pull meedamian/simple-qemu:v5.0.1-enable-build1