Docker镜像未运行。

huangapple go评论85阅读模式
英文:

Docker image not running

问题

我已经成功构建了我的Docker镜像,所以我正在尝试运行它,但是我遇到了这个错误。这可能听起来很愚蠢,但我对Docker不是很熟悉。

这是我的Dockerfile 这是我遇到的错误

如果你能帮我解决问题,我将非常感激。我也不知道如何在stackoverflow上提问。无论如何,如果你能理解我的意思,你的回复将受到高度赞赏。

英文:

I've successfully built my docker image, so I'm trying to run it, I'm getting this error. This may sound stupid, but I'm not an expert in docker

This is my DockerfileThis is the error I'm getting

Pls if you can help me out. I also don't know how to use this stackoverflow to ask questions tho. Anyway you could understand what i'm saying, your response would be high appreciated

答案1

得分: 0

当你构建它时,你将它放在/Portfolio_Backend目录下,但是当你在CMD语句中运行它时,你运行的是/app/Portfolio_Backend。这就是为什么它找不到它的原因。

你可能想要的是将可执行文件放在app目录中,所以将你的构建命令改为:

RUN go build -o Portfolio_Backend

即删除名称中的前导斜杠。然后它将位于app目录中,并且应该可以正常工作。

另外,请注意在Stack Overflow上发布文本图片是不被赞同的。原因是对于任何想要尝试重现你的问题的人来说,从你的图片中复制/粘贴是很困难的。

英文:

When you build it, you put it in /Portfolio_Backend, but when you run it in the CMD statement, you run /app/Portfolio_Backend. That's why it can't find it.

What you want is probably to have the executable in the app directory, so change your build command to

RUN go build -o Portfolio_Backend

i.e. remove the leading slash in the name. Then it'll be in the app directory and it should work.

Also please note that posting images of text is frowned upon on Stack Overflow. The reason is that it's hard to copy/paste from your images for anyone that wants to try to reproduce your issue.

huangapple
  • 本文由 发表于 2023年4月24日 00:15:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76085937.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定