Don’t Build to Wrong Platform

Did you know that when you build a Docker image on your PC or server, the Docker platform will, by default, use your machine’s architecture?
But wait — what is the Docker platform? The Docker platform is a tag in the docker build
command that specifies which architecture the image will be built for.
For example, if your machine (e.g., PC) uses linux/arm64
, but your server uses linux/amd64
, what will happen? The image won't be able to run as a container.
So, how do you force it? After searching through various forums, I found this command that needs to be run before starting the container:
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
But what does this command actually do?


As you can see, the container starts and runs perfectly, but it significantly increases memory usage. The resource consumption starts from a normal 56MB to 550MB just because I forced it. (Ignore the CPU% difference, it’s still at the same average)
Then i found this official docker article about multi-platform. I felt so stupid for not finding it earlier! Now I know that Docker can build multi-platform images (+1 knowledge).
But why does QEMU cause such high memory consumption? Here’s what GPT said
You’re using QEMU for emulating an ARM architecture on an AMD64 (x86_64) server, which is causing the high RAM usage. This happens because:
1. QEMU emulation overhead: Running an ARM binary on x86_64 requires translation, which increases memory usage.
2. Memory allocation differences: Some ARM binaries are optimized for a different memory footprint and may not be efficient on an x86_64 environment.
I don’t want to verify whether it’s true or not, but my brain accepts it.

Then I tried to build a multi-platform Docker image. I knew it would increase the registry image size, but as long as it didn’t add to my frustration and concern over memory consumption, I was as happy as I could be.
Member discussion