Forcing docker to use linux/amd64 platform by default on macOS
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
To force Docker to default to linux/amd64 on macOS with Apple Silicon, set the DOCKER_DEFAULT_PLATFORM environment variable in your shell profile. This is a single line that makes every docker run, docker build, and docker compose command target x86_64 unless you explicitly override it.
After saving, run source ~/.zshrc or open a new terminal. Every Docker command in that shell will now default to the amd64 platform.
Why This Is Necessary on Apple Silicon
Apple's M-series chips use the ARM64 (aarch64) architecture. Docker on Apple Silicon defaults to pulling and building linux/arm64 images. This causes problems when:
- The image you need 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 pipeline runs on x86_64 Linux servers, and you want local builds to match production exactly.
- A multi-service
docker-compose.ymlmixes images where some have ARM support and others do not.
When Docker cannot find an ARM variant of the image, you see errors like:
Or worse, the container starts but crashes at runtime because a binary inside it was compiled for the wrong architecture.
Three Ways to Force the Platform
1. Environment variable (global default)
This is the recommended approach for developers who consistently need amd64 images:
Every Docker command inherits this setting. You can override it per-command with --platform linux/arm64 when needed.
2. Per-command flag
For one-off commands where you want to target a specific platform without changing the global default:
3. Docker Compose platform field
In docker-compose.yml, you can specify the platform per service:
This is useful when only specific services need amd64 and others run fine on ARM.
Comparison of Approaches
| 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 |
Setting Platform in the Dockerfile
You can pin the platform directly in the Dockerfile so it is architecture-explicit regardless of the host machine:
This approach is useful when the Dockerfile will be built on both ARM and x86_64 machines but the resulting image must always be amd64 (for example, deploying to x86_64 cloud servers).
Performance Impact of Emulation
Running amd64 containers on Apple Silicon requires QEMU emulation, which Docker Desktop includes automatically. The performance cost is real and measurable.
| 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 |
For daily development, a 3-4x slowdown on builds is noticeable but manageable. For running databases or I/O-intensive services, consider using the native ARM variant when one exists and only forcing amd64 for services that require it.
Using Rosetta for Better Emulation Performance
Docker Desktop 4.25 and later supports Apple's Rosetta 2 for x86_64 emulation, which is significantly faster than QEMU for many workloads.
To enable it:
- Open Docker Desktop Settings.
- Go to General.
- Check "Use Rosetta for x86_64/amd64 emulation on Apple Silicon."
- Click Apply and Restart.
Rosetta typically cuts the emulation overhead in half compared to QEMU, though results vary by workload.
Multi-Platform Builds with Buildx
If you need to produce images for both architectures (for example, publishing a library), Docker Buildx handles this:
This builds the image twice (once per architecture) and pushes a manifest list so that Docker automatically pulls the correct variant on any machine.
Verifying the Active Platform
After setting the environment variable, verify it is working:
When to Use ARM Native Instead
Forcing amd64 everywhere is a blunt instrument. As ARM support in the Docker ecosystem has matured, many popular images now publish ARM variants. Consider using 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 approach is to force amd64 only for the specific services that need it and let everything else run natively.
Common Pitfalls
Setting the env var but not reloading the shell. After adding DOCKER_DEFAULT_PLATFORM to ~/.zshrc, you must run source ~/.zshrc or open a new terminal. The old shell session still uses the previous setting.
Forgetting to pull fresh images after changing platforms. If you previously pulled mysql:8.0 as an ARM image, Docker may use the cached ARM layer. Run docker pull --platform linux/amd64 mysql:8.0 to force a fresh pull, or remove the old image first.
Applying amd64 globally when only one service needs it. This slows down every container unnecessarily. Use per-service platform in Compose or per-command --platform flags to limit the impact.
Ignoring Rosetta. If you are on Docker Desktop 4.25 or later and running emulated amd64 containers, enabling Rosetta can cut emulation overhead significantly. There is no downside to turning it on.
Assuming emulation is identical to native. Some workloads expose subtle differences under emulation, particularly those involving low-level system calls, JIT compilation, or memory-mapped I/O. If you hit unexplained crashes only in emulated containers, test on a native amd64 machine to isolate the cause.
Summary
- Set
export DOCKER_DEFAULT_PLATFORM=linux/amd64in~/.zshrcto make Docker default to x86_64 images on Apple Silicon. - Use
--platform linux/amd64on individual commands for one-off overrides. - Use the
platformfield indocker-compose.ymlfor per-service control. - Pin
FROM --platform=linux/amd64in Dockerfiles when the image must always target x86_64 regardless of the build host. - Enable Rosetta in Docker Desktop for faster emulation.
- Emulated amd64 runs 2-4x slower than native ARM. Only force amd64 for services that genuinely require it.
- Use
docker buildxfor multi-platform builds when publishing images that need to run on both architectures.
Related reading
- Forward host port to docker container
- Forward HTTPS client ip from Google Container Engine
- From inside of a Docker container, how do I connect to the localhost of the machine?
- 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

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.