在$PATH中找不到可执行文件:未知错误消息

我在$PATH中找不到可执行文件:尝试运行golang项目的docker映像时出现未知错误。以下是我的 docker 文件。


FROM golang:latest

LABEL maintainer = "Nisal Perera <xxx@sss.com>"

RUN mkdir -p /go/src/github.com/user/app/

COPY . /go/src/github.com/user/app/

WORKDIR /go/src/github.com/user/app/

RUN go get -u github.com/golang/dep/cmd/dep

#RUN dep init

RUN dep ensure

RUN go build

CMD ["go run main.go"]

我得到的错误如下


docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "go run main.go": executable file not found in $PATH: un

known.

请帮帮我。谢谢


烙印99
浏览 344回答 3
3回答

冉冉说

你不需要使用,因为你以前运行过,构建的文件将以目录命名,看起来像它的,试试go run ...go buildappCMD ["./app"]顺便说一句,在你的情况下,正确的用法是,你的错误与命令有关,它假设是一个文件,但它不是。CMDCMD ["go", "run", "main.go"]CMDgo run main.go

守着星空守着你

您正在尝试以&nbsp;exec&nbsp;形式使用子句,因此必须拆分命令及其参数。接受的格式为CMDCMD&nbsp;["executable","param1","param2"]所以你的会CMD&nbsp;["go",&nbsp;"run",&nbsp;"main.go"]

小怪兽爱吃肉

您会收到此错误,因为文件“main.go”在执行“go run main.go”命令的工作目录中不可用。请检查main.go文件是否可用,如果是,请定义main.go文件的完整路径并尝试。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go