K
K
Konstantin2016-08-30 20:11:42
linux
Konstantin, 2016-08-30 20:11:42

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

sh main

main: line 1: ELF: not found
main: line 2: syntax error: unexpected "("

what are the samples

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
mureevms, 2016-08-30
@happy_yar

Under alpine, you need to compile under alpine itself, because. it has its own implementation of libc. Do it in the container itself.

A
Alexander Pavlyuk, 2016-08-30
@pav5000

Have you set permissions to run the file?
chmod +x main
Are you typing the command while in the folder with the binary?

G
gaxetasok, 2017-05-14
@gaxetasok

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 question

Ask a Question

731 491 924 answers to any question