Answer the question
In order to leave comments, you need to log in
How to run binary in Linux Alpine docker container?
There is a docker - I put the generated binary go build main.go (GOARCH="amd64", GOOS="linux") in the docker file and
run it. /main
sh: main: not found
main: line 1: ELF: not found
main: line 2: syntax error: unexpected "("
Answer the question
In order to leave comments, you need to log in
Under alpine, you need to compile under alpine itself, because. it has its own implementation of libc. Do it in the container itself.
Have you set permissions to run the file?
chmod +x main
Are you typing the command while in the folder with the binary?
Let me guess - you compiled a Go program on Windows????
You need cross-compilation
Specify the environment variables before starting the compiler
GOOS=linux
GOARCH=amd64 (if your Alpina is 64-bit)
The resulting file will run fine under Alpina, but will not run under Windows. This is fine.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question