By coincidence, I discovered today that two binaries compiled on my MacBook Pro 2017 using cross-compiling with two different architectures both work inside the same ubuntu:latest
docker container. Here is what happened:
I first compiled a hello-world running env GOOS=linux GOARCH=amd64 go build
, lets call this binary A. I then compiled the same hello-world program running env GOOS=linux GOARCH=arm64 go build
, lets call this binary B.
I check the md5sum of A and B and made sure that they were different binaries. I copied both of these binaries into the same docker container running ubuntu:latest
as its base, expecting B to fail when executing. However, they were both executed perfectly.
Similarly, a binary compiled using env GOOS=linux GOARCH=ppc64 go build
will not execute inside the same docker container. Does anyone know why this is?
For reference, the output of uname -sm
on my MacBook gives Darwin x86_64
. The output of uname -sm
inside my docker container running ubuntu:latest
gives Linux x86_64