相关疑难解决方法(0)

standard_init_linux.go:190: exec 用户进程在运行 Go 二进制文件时导致“exec 格式错误”

我正在尝试使用 Go 二进制文件创建一个容器,用作数据库迁移器。但是,如果我运行二进制文件,它可以完美运行,但是,我正在努力将它放入容器中并在我的 docker-compose 堆栈中运行它。

下面是我的 Dockerfile。

FROM golang:1.11 AS build_base

WORKDIR /app

ENV GO111MODULE=on
# We want to populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .
RUN go mod download

FROM build_base AS binary_builder
# Here we copy the rest of the source code
COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build

#In this last stage, we start from a fresh Alpine image, to reduce the image size and not ship …
Run Code Online (Sandbox Code Playgroud)

go docker

8
推荐指数
1
解决办法
7304
查看次数

标签 统计

docker ×1

go ×1