Working with Docker environments amid diverse architectures, like Apple’s
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:
With this command, Docker enforces x86 architecture by default on commands supporting
--platform parameter, streamlining workflows and sparing the need for repetitive
For specific commands requiring alternate platforms, it’s fine to use it like:
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.