
OS Kinda/GNU/Linux
Run x86_64 (linux/amd64) containers and other Linux architectures on an Apple
Silicon Mac using Lima, Docker, and QEMU user-mode emulation. ARM64 containers
run natively; other architectures run through emulation and can be slower.
Steps
- Install Lima and the Docker command-line tools.
- Create and start a Lima VM named
docker. - Register the multiarch emulators inside the VM.
- Test the architectures provided by a container image.
Step 1: Install Lima and Docker CLI
Lima manages GNU/Linux virtual machines on macOS. The
docker VM runs the Docker daemon. The macOS docker package supplies the local
CLI, which connects to that daemon.
brew install lima docker docker-compose
Add cliPluginsExtraDirs to ~/.docker/config.json to enable docker compose:
{
"cliPluginsExtraDirs": [
"/opt/homebrew/lib/docker/cli-plugins"
]
}
docker compose version
Step 2: Create and start the Docker VM
limactl create --name=docker --arch=aarch64 \
--set='.base[0] = "template:_images/debian-13"' \
template:docker-rootful
Configure mount points before confirming creation.
The rootful template
is required for binfmt_misc registration. Lima’s template:docker uses a
rootless daemon, where --privileged cannot grant access to the VM’s kernel.
limactl start docker
docker context create lima-docker --docker \
"host=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')"
docker context use lima-docker
docker run --rm hello-world
If the context already exists, skip docker context create.
Step 3: Enable multiarch
The tonistiigi/binfmt project, maintained
by Tonis Tiigi and contributors, distributes QEMU emulators and registers them
with Linux’s binfmt_misc facility.
#!/usr/bin/env bash
set -euo pipefail
VM="docker"
limactl shell "$VM" -- \
docker run --privileged --rm tonistiigi/binfmt --install all
If the daemon requires sudo, use sudo docker after --.
For x86_64 support alone, replace --install all with --install amd64.
Output:
installing: arm OK
installing: s390x OK
installing: ppc64le OK
installing: 386 OK
installing: mips64le OK
installing: mips64 OK
installing: loong64 OK
installing: riscv64 OK
installing: amd64 OK
{
"supported": [
"linux/arm64",
"linux/amd64",
"linux/amd64/v2",
"linux/riscv64",
"linux/ppc64le",
"linux/s390x",
"linux/386",
"linux/mips64le",
"linux/mips64",
"linux/loong64",
"linux/arm/v7",
"linux/arm/v6"
],
"emulators": [
"python3.14",
"qemu-arm",
"qemu-i386",
"qemu-loongarch64",
"qemu-mips64",
"qemu-mips64el",
"qemu-ppc64le",
"qemu-riscv64",
"qemu-s390x",
"qemu-x86_64"
]
}
After restarting the VM, rerun the installer if the handlers are missing.
Step 4: Test the architectures
Interactive x86_64 test
docker run --platform linux/amd64 --rm -it alpine:latest /bin/sh
Inside the container, uname -m should print x86_64.
Full architecture test
Run with Bash on macOS. Requires GNU timeout inside the VM.
Alpine does not provide images for every registered handler, such as MIPS.
#!/usr/bin/env bash
set -uo pipefail
VM="docker"
IMAGE="alpine:latest"
TIMEOUT=60
PULL_TIMEOUT=180
vm() {
limactl shell "$VM" -- "$@"
}
# Detect whether the rootful Docker daemon requires sudo inside the VM.
if vm docker info >/dev/null 2>&1; then
DOCKER=(docker)
elif vm sudo -n docker info >/dev/null 2>&1; then
DOCKER=(sudo -n docker)
else
echo "ERROR: Docker is not available inside VM '$VM'"
exit 1
fi
if ! vm timeout --version >/dev/null 2>&1; then
echo "ERROR: GNU timeout is required inside VM '$VM'"
exit 1
fi
docker_vm() {
vm "${DOCKER[@]}" "$@"
}
# A timeout can stop the client while leaving its container running.
CONTAINER="multiarch-test-$$"
cleanup() {
docker_vm rm -f "$CONTAINER" >/dev/null 2>&1 || true
}
trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
# platform|expected uname -m
ARCHITECTURES=(
"linux/amd64|x86_64"
"linux/arm64|aarch64"
"linux/arm/v7|armv7l"
"linux/386|i686"
"linux/ppc64le|ppc64le"
"linux/s390x|s390x"
"linux/riscv64|riscv64"
)
PASS=0
FAIL=0
SKIP=0
RESULTS=()
echo "========================================"
echo " Multi-architecture Docker test"
echo "========================================"
echo
echo "VM: $VM"
echo "Image: $IMAGE"
echo "Host kernel: $(vm uname -s)"
echo "Host arch: $(vm uname -m)"
echo
echo "Registered binfmt handlers:"
vm bash -lc '
if [ -d /proc/sys/fs/binfmt_misc ]; then
find /proc/sys/fs/binfmt_misc \
-maxdepth 1 \
-type f \
-printf "%f\n" 2>/dev/null |
grep -vE "^(register|status)$" |
sort || true
else
echo "binfmt_misc is not mounted"
fi
'
echo
for entry in "${ARCHITECTURES[@]}"; do
IFS='|' read -r platform expected <<< "$entry"
printf "%-18s " "$platform"
pull_output="$(
vm timeout "$PULL_TIMEOUT" "${DOCKER[@]}" pull \
--platform "$platform" "$IMAGE" 2>&1
)"
pull_rc=$?
if (( pull_rc != 0 )); then
if [[ "$pull_output" == *"no matching manifest for $platform"* ]]; then
echo "SKIP - image unavailable"
RESULTS+=("SKIP|$platform|image unavailable")
((SKIP++))
else
echo "FAIL - image pull failed"
echo " $pull_output"
RESULTS+=("FAIL|$platform|image pull failed (exit $pull_rc)")
((FAIL++))
fi
continue
fi
output="$(
vm timeout "$TIMEOUT" "${DOCKER[@]}" run \
--name "$CONTAINER" --platform "$platform" \
--pull=never --rm "$IMAGE" uname -m 2>&1
)"
rc=$?
cleanup
if (( rc != 0 )); then
echo "FAIL - container exited with status $rc"
echo " $output"
RESULTS+=("FAIL|$platform|container failed (exit $rc)")
((FAIL++))
continue
fi
actual="$(printf '%s' "$output" | tr -d '\r\n')"
if [[ "$actual" == "$expected" ]]; then
echo "PASS - $actual"
RESULTS+=("PASS|$platform|$actual")
((PASS++))
else
echo "FAIL - expected '$expected', got '$actual'"
RESULTS+=("FAIL|$platform|expected $expected, got $actual")
((FAIL++))
fi
done
echo
echo "========================================"
echo " Results"
echo "========================================"
printf "%-8s %-18s %s\n" "STATUS" "PLATFORM" "RESULT"
printf "%-8s %-18s %s\n" "------" "--------" "------"
for result in "${RESULTS[@]}"; do
IFS='|' read -r status platform message <<< "$result"
printf "%-8s %-18s %s\n" "$status" "$platform" "$message"
done
echo
echo "PASS: $PASS"
echo "FAIL: $FAIL"
echo "SKIP: $SKIP"
if (( FAIL > 0 )); then
echo "One or more architectures failed."
exit 1
fi
if (( PASS == 0 )); then
echo "No architectures were tested successfully."
exit 1
fi
echo "All available architectures passed."
Example output
========================================
Multi-architecture Docker test
========================================
VM: docker
Image: alpine:latest
Host kernel: Linux
Host arch: aarch64
Registered binfmt handlers:
python3.14
qemu-arm
qemu-i386
qemu-loongarch64
qemu-mips64
qemu-mips64el
qemu-ppc64le
qemu-riscv64
qemu-s390x
qemu-x86_64
linux/amd64 PASS - x86_64
linux/arm64 PASS - aarch64
linux/arm/v7 PASS - armv7l
linux/386 PASS - i686
linux/ppc64le PASS - ppc64le
linux/s390x PASS - s390x
linux/riscv64 PASS - riscv64
========================================
Results
========================================
STATUS PLATFORM RESULT
------ -------- ------
PASS linux/amd64 x86_64
PASS linux/arm64 aarch64
PASS linux/arm/v7 armv7l
PASS linux/386 i686
PASS linux/ppc64le ppc64le
PASS linux/s390x s390x
PASS linux/riscv64 riscv64
PASS: 7
FAIL: 0
SKIP: 0
All available architectures passed.