I use cross compile to compile a linux version binary on Mac.
GOOS=linux GOARCH=amd64 go build
Also tried the other command that I found on stack overflow.
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o targetBinary
This binary can run in Linux VM. But when I copy this binary to a linux docker container and run it. It can not run anymore.
My docker file is like this
FROM oraclelinux:7.5
COPY targetBinary /
I also use ldd to check target and docker reports this result
[root@7578c118fe27 /]# ldd targetBinary
not a dynamic executable