Standard_init_linux.go:211: exec user process caused “exec format error”

Viewed 1280

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"]
2 Answers
  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"]

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
Related