Solve docker running standard_init_linux.go:219: exec user process caused: exec format error

created at 10-12-2021 views: 101

error

Using mac M1 build image, running on linux report 

standard_init_linux.go:219: exec user process caused: exec format error

solution

The main reason for this problem is that golang compilation cannot be cross-platform, that is, different systems or different CPU cores will cause this error. 

Golang code compiled under linux arm cannot be run under linux X86; similarly, mirroring of projects containing golang code cannot be cross-platform. 

The solution is very simple. When building, add the --platform linux/amd64 parameter

docker build --platform linux/amd64 -t tag
created at:10-12-2021
edited at: 10-12-2021: