2

The following code generates an error: standard_init_linux.go:211: exec user process caused “exec format error”

Any pointers to what I’m doing wrong?

FROM golang:alpine AS builder
 
ENV GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOARCH=wasm GOOS=js

WORKDIR /build

COPY . .

COPY wasm_exec.js . 
COPY server.go . 
COPY main.wasm . 
COPY manifest.json . 
COPY sw.js . 
COPY wasm_exec.js . 
COPY app.js . 
COPY index.html .

EXPOSE 8989 
ENTRYPOINT ["./server.go"]
1
  • You need to compile ./server.go (go build etc.) and then have that resulting binary as your entry-point. Commented May 29, 2020 at 3:45

2 Answers 2

2
  1. To use dos2unix fix your files' format, which maybe changed by git from lf to crlf
  2. go build before copy to docker, then, copy and execute the bin
  3. if you don't want to do pre-built, the last line should be ENTRYPOINT ["go","run","./server.go"]
Sign up to request clarification or add additional context in comments.

Comments

1

The error is because you are trying to execute server.go file without compiling you need to compile server.go to get the executable which then can be used as executable.

go build server.go

Or you can directly run it using

go run server.go

1 Comment

After adding to the end of the Dockerfile CMD ["go", "run", "server.go"] I get a new error: fork/exec /tmp/go-build004673479/b001/exe/server: exec format error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.