Docker
macOS
linux/amd64
containerization
cross-platform compatibility

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.

bash
# Add to ~/.zshrc (or ~/.bashrc)
export DOCKER_DEFAULT_PLATFORM=linux/amd64

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 amd64 variant (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.yml mixes images with and without ARM support.

When there is a mismatch, you see warnings like:

text
WARNING: The requested image's platform (linux/amd64) does not match
the detected host platform (linux/arm64/v8)

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:

bash
# ~/.zshrc
export DOCKER_DEFAULT_PLATFORM=linux/amd64

Override it per command with --platform linux/arm64 when needed.

--platform on a single command

bash
1# Pull an amd64 image explicitly
2docker pull --platform linux/amd64 mysql:8.0
3
4# Run with platform override
5docker run --platform linux/amd64 --rm mysql:8.0 mysql --version
6
7# Build for amd64
8docker build --platform linux/amd64 -t myapp:latest .

platform per service in Docker Compose

Useful when only some services need amd64:

yaml
1services:
2  database:
3    image: mysql:8.0
4    platform: linux/amd64
5    environment:
6      MYSQL_ROOT_PASSWORD: dev
7    ports:
8      - '3306:3306'
9
10  app:
11    build:
12      context: .
13      dockerfile: Dockerfile
14      platforms:
15        - linux/amd64
16    ports:
17      - '8080:8080'
18    depends_on:
19      - database

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:

dockerfile
1FROM --platform=linux/amd64 node:20-slim AS builder
2WORKDIR /app
3COPY package*.json ./
4RUN npm ci
5COPY . .
6RUN npm run build
7
8FROM --platform=linux/amd64 node:20-slim
9WORKDIR /app
10COPY --from=builder /app/dist ./dist
11COPY --from=builder /app/node_modules ./node_modules
12CMD ["node", "dist/index.js"]
ApproachScopePersistenceOverride Needed
DOCKER_DEFAULT_PLATFORM env varAll Docker commands in the shellUntil shell profile is changed--platform linux/arm64 per command
--platform flagSingle commandNoneNot applicable
Compose platform fieldSingle servicePer projectOverride in compose override file
Dockerfile FROM --platformSingle build stagePer DockerfileRebuild required

The cost of emulating amd64

Running amd64 containers on Apple Silicon uses QEMU emulation, which Docker Desktop includes automatically. The slowdown is real:

OperationNative ARM64Emulated amd64Slowdown
Node.js build (npm ci)30s90-120s3-4x
Python pip install20s60-80s3-4x
Database queries (MySQL)Baseline1.5-2x slower1.5-2x
File I/O heavy workloadsBaseline2-5x slower2-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:

  1. Open Docker Desktop Settings.
  2. Go to General.
  3. Check "Use Rosetta for x86_64/amd64 emulation on Apple Silicon."
  4. 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:

bash
1# Create a builder that supports multiple platforms
2docker buildx create --name multiplatform --use
3
4# Build and push for both architectures
5docker buildx build \
6  --platform linux/amd64,linux/arm64 \
7  -t myregistry/myapp:latest \
8  --push .

This builds once per architecture and pushes a manifest list, so Docker pulls the correct variant on any machine.

Checking which platform is active

bash
1# Check the environment variable
2echo $DOCKER_DEFAULT_PLATFORM
3
4# Verify the platform of a running container
5docker run --rm alpine uname -m
6# Expected output: x86_64 (if amd64 is forced)
7# Would show: aarch64 (if running natively on ARM)
8
9# Check the platform of a pulled image
10docker inspect --format '{{.Os}}/{{.Architecture}}' alpine:latest

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.


Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design