How to run an ARM64 Docker container on a x86-64 host?
Jun 3, 9:38pm

Running an ARM64 Docker container on an x86-64 host requires emulation, as the architectures are incompatible. Here’s how to do it efficiently:


1. Use Docker’s Built-in Emulation (Recommended)

Docker Desktop (macOS/Windows) and newer versions of Docker Engine (Linux) support multi-architecture emulation via binfmt_misc and QEMU.

Steps:

A. Install QEMU and binfmt_misc

  • Linux (Ubuntu/Debian):
    bash
    sudo apt-get update
    sudo apt-get install -y qemu-user-static binfmt-support
  • Docker Desktop (macOS/Windows): Emulation is enabled by default for ARM64 containers.

B. Pull the ARM64 Image

Docker will automatically use QEMU to emulate ARM64:

bash
docker pull --platform linux/arm64 <image_name>

Example:

bash
docker pull --platform linux/arm64 nginx:latest

C. Run the Container

bash
docker run --platform linux/arm64 -it <image_name>

Example:

bash
docker run --platform linux/arm64 -it nginx:latest

2. Use Buildx for Multi-Architecture Builds

If you’re building ARM64 images on x86-64, use Docker’s buildx:

bash
docker buildx create --use
docker buildx build --platform linux/arm64 -t <image_name> .

3. Manual QEMU Setup (Advanced)

If Docker’s emulation doesn’t work, manually register QEMU:

bash
docker run --privileged --rm tonistiigi/binfmt --install all

Performance Note

  • Emulation adds overhead (slower execution).
  • For production, use native ARM64 hardware or cross-compile your app.

Troubleshooting

  • If you get exec format error, ensure qemu-user-static is installed and binfmt_misc is configured.
  • Check Docker’s emulation support:
    bash
    docker info | grep -i emulation

Would you like help with a specific image or use case?

Jun 3, 9:38pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more