1. 程式人生 > 其它 >standard_init_linux.go:211: exec user process caused “exec format error“

standard_init_linux.go:211: exec user process caused “exec format error“

技術標籤:學習資料學習中學習的習題開發遇到的問題DockerGoBeego

使用docker部署Golang的beego專案

dockerfile內容

FROM golang:1.15.5

ENV GOPROXY=https://goproxy.io,direct
ENV GOSUMDB=off

WORKDIR /
COPY go.mod ./
RUN go mod download

COPY . .

RUN chmod 777 ./test-go
ENTRYPOINT ["./test-go"]

執行容器:

docker run -p 2098:8080 --name test-go test-go

報錯:

解決方案:

FROM golang:1.15.5 as builder

ENV GOPROXY=https://goproxy.cn
ENV GOSUMDB=off

WORKDIR /
COPY go.mod ./
RUN go mod download

COPY . .

RUN CGO_ENABLED=0 go build  -o test-go -a -ldflags '-s'

FROM scratch
COPY --from=builder test-go /test-go
COPY --from=builder conf/ /conf/
CMD ["/test-go"]