Force Docker to use linux/amd64 by default on macOS
Codemia Knowledge Hub ·
To make Docker default to linux/amd64 on an Apple Silicon Mac, set the DOCKER_DEFAULT_PLATFORM environment variable in your shell profile. Every docker run, docker build and docker compose command then targets x86_64 unless you override it.
Run source ~/.zshrc or open a new terminal for it to take effect.
Why Apple Silicon needs this
M-series chips are ARM64 (aarch64), so Docker on Apple Silicon pulls and builds linux/arm64 images by default. That causes problems when:
- The image only publishes an
amd64variant (common with older or niche images). - A native dependency inside the image was compiled for x86_64 and has no ARM build.
- Your CI/CD runs on x86_64 Linux and you want local builds to match production.
- A multi-service
docker-compose.ymlmixes images with and without ARM support.
When there is a mismatch, you see warnings like:
Or the container starts and then crashes because a binary inside it targets the wrong architecture.
Ways to set the platform
Environment variable (global default)
The recommended option if you consistently need amd64:
Override it per command with --platform linux/arm64 when needed.
--platform on a single command
platform per service in Docker Compose
Useful when only some services need amd64:
FROM --platform in the Dockerfile
Pinning the platform in the Dockerfile makes the image amd64 regardless of the build host, which suits Dockerfiles built on both ARM and x86_64 machines but deployed to x86_64 cloud servers:
| Approach | Scope | Persistence | Override Needed |
DOCKER_DEFAULT_PLATFORM env var | All Docker commands in the shell | Until shell profile is changed | --platform linux/arm64 per command |
--platform flag | Single command | None | Not applicable |
Compose platform field | Single service | Per project | Override in compose override file |
Dockerfile FROM --platform | Single build stage | Per Dockerfile | Rebuild required |
The cost of emulating amd64
Running amd64 containers on Apple Silicon uses QEMU emulation, which Docker Desktop includes automatically. The slowdown is real:
| Operation | Native ARM64 | Emulated amd64 | Slowdown |
Node.js build (npm ci) | 30s | 90-120s | 3-4x |
| Python pip install | 20s | 60-80s | 3-4x |
| Database queries (MySQL) | Baseline | 1.5-2x slower | 1.5-2x |
| File I/O heavy workloads | Baseline | 2-5x slower | 2-5x |
A 3-4x slower build is noticeable but manageable for daily work. For databases or I/O-heavy services, use the native ARM variant when one exists and force amd64 only where required.
Enabling Rosetta for faster emulation
Docker Desktop 4.25 and later can use Apple's Rosetta 2 for x86_64 emulation, which is significantly faster than QEMU for many workloads:
- Open Docker Desktop Settings.
- Go to General.
- Check "Use Rosetta for x86_64/amd64 emulation on Apple Silicon."
- Click Apply and Restart.
Rosetta typically halves the emulation overhead compared to QEMU, though results vary by workload.
Building for both architectures with Buildx
To publish images for amd64 and arm64:
This builds once per architecture and pushes a manifest list, so Docker pulls the correct variant on any machine.
Checking which platform is active
When to stay on native ARM
Forcing amd64 everywhere is a blunt instrument. Prefer native ARM images when:
- The image has an official ARM variant (most major images do: Node, Python, PostgreSQL, Redis, Nginx).
- You are not deploying to x86_64 servers, or your CI handles the architecture difference.
- Build or runtime performance matters (native is 3-4x faster than emulated).
A pragmatic setup forces amd64 only for the services that need it.
Problems after switching platforms
Not reloading the shell. After adding DOCKER_DEFAULT_PLATFORM to ~/.zshrc, run source ~/.zshrc or open a new terminal. The old session keeps the previous setting.
Cached ARM images. If you already pulled mysql:8.0 as ARM, Docker may reuse the cached layer. Run docker pull --platform linux/amd64 mysql:8.0 or remove the old image first.
Forcing amd64 globally for one service. That slows every container. Use the Compose platform field or per-command --platform instead.
Leaving Rosetta off. On Docker Desktop 4.25 or later with emulated amd64 containers, enabling Rosetta cuts overhead significantly, with no downside.
Assuming emulation is identical to native. Low-level system calls, JIT compilation and memory-mapped I/O can behave differently under emulation. If you see crashes only in emulated containers, test on a native amd64 machine to isolate the cause.
Related reading
- Forward host port to docker container
- Forward HTTPS client ip from Google Container Engine
- Get current image of kubernetes deployment
- Get docker-compose.yml file location from running container?
- Get Docker container id from container name
- Get Environment Variable from Docker Container
- Get replica set of the deployment
- Get the image and SHA image ID of images in pod on Kubernetes deployment
System design interview problems on this topic
- Design a Container Orchestration System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design GitHub Actions: solution and walkthrough
- Design a Serverless Architecture Framework: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.