Working with Docker environments amid diverse architectures, like Apple’s arm64 and x86-64/AMD64, presents challenges. I’ve encountered the clash between my Mac’s M1 arm64 architecture and my x86-centric server workloads. The solution? Just use DOCKER_DEFAULT_PLATFORM 1 2.

Just run in the terminal:

Enforce platform for all commands
export DOCKER_DEFAULT_PLATFORM=linux/amd64

With this command, Docker enforces x86 architecture by default on commands supporting --platform parameter, streamlining workflows and sparing the need for repetitive --platform specifications.

For specific commands requiring alternate platforms, it’s fine to use it like:

Enforce platform for all commands
docker run --rm -ti --platform linux/arm64 ubuntu:22.04 uname -a
docker run --rm -ti --platform linux/amd64 ubuntu:22.04 uname -a

But by setting DOCKER_DEFAULT_PLATFORM, working with Docker environments becomes intuitive, allowing me to focus on building and deploying instead of fighting with my hardware.


Of course it’s slower than running on native platform (because of virtualization), but I prefer to wait a little bit longer over fixing silly bugs, which I wouldn’t have on proper architecture.