我正在尝试使用 -race 从 go stretch 构建,然后将其复制到小型高山容器以减小最终大小。但是我在启动时遇到了这个错误:
standard_init_linux.go:211: exec user process caused "no such file or directory"
我的 Dockerfile:
FROM golang:1.12.6-stretch as build-env
WORKDIR /goman/
ADD . .
RUN GOFLAGS=-mod=vendor go test -race -v ./...
RUN CGO_ENABLED=0 GOBIN=/goman/apps/ GOOS=linux GOARCH=amd64 go install -v \
-a -tags netgo -installsuffix netgo -mod vendor -ldflags "-d -s -w" ./cmd/...
FROM alpine:3.10
RUN apk add --no-cache ca-certificates tzdata
COPY --from=build-env /goman/apps/ /apps
COPY --from=build-env /goman/conf /conf
WORKDIR /apps/
sh`ing在容器中时我可以清楚地看到文件并且权限正确