Docker:无法计算缓存密钥:&quord; quirements.txt"找不到:找不到

发布于 2025-01-29 06:54:55 字数 415 浏览 4 评论 0 原文

我尝试使用以下命令来构建Docker映像:

Docker Build - < Dockerfile

我在应用程序的主要目录中完成了此操作。我在文档“如何构建Docker映像”中找到了此命令。但是,由于失败而失败的构建:

无法计算缓存键:“/requirements.txt”找不到:找不到

我的test-app结构看起来像:

.
+-- src
|   +-- static
|   +-- templates
|   +-- app.py
+-- Dockerfile
+-- requirements.txt

我不是docker专家,有几个说明。有些令人沮丧。其他堆栈溢出问题无法解决我的问题。

我在做什么错?

I tried to build a docker image with the following command:

docker build -< Dockerfile

I did it in the main directory of the app. I found this command somewhere in a documentation "how to build a docker image". However the build failed with failure:

failed to compute cache key: "/requirements.txt" not found: not found

My test-app structure looks like:

.
+-- src
|   +-- static
|   +-- templates
|   +-- app.py
+-- Dockerfile
+-- requirements.txt

I'm not a docker expert and there are several instructions out there. It's somehow frustrating. Other stack overflow questions did not solve my issue.

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稍尽春風 2025-02-05 06:54:55

经过一番调查并尝试一下,我找到了以下解决方案:

命令 docker build-&gt; Dockerfile 有些错误。不知道它是过时的还是不完整的。

但是,我使用以下命令,并且可以使用:

docker build -tag docker_example。

非常重要的是and and and。没有这个,它将无效。它告诉Docker使用哪个Dockerfile。

如果您有一个“自定义” dockerfile名称,例如“ sothing.dockerfile”,则必须添加-f选项,然后添加dockerfile的名称才能构建正确的dockerfile。

示例:

docker build -tag docker_example -f somings.dockerfile。

After some investigation and try out i found the following solution:

The command docker build -> Dockerfile was somehow wrong. Don't know if it is outdated or incomplete.

However i used the following command and it worked:

docker build --tag docker_example .

Very important is the dot at the and. Without this it will not work. It tells Docker which Dockerfile to use.

If you have a "custom" Dockerfile name like "something.Dockerfile" you have to add the -f option followed by the name of your Dockerfile to build the right one.

Example:

docker build --tag docker_example -f something.Dockerfile .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文