Docker配置找不到现有文件? [英] Docker configuration does not find existing file?

查看:228
本文介绍了Docker配置找不到现有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在IntelliJ Rider中配置和运行docker文件.

I try to configure and run a docker file in IntelliJ Rider.

在构建期间,出现以下错误:

During the build, I get the following error:

Step 7/17 : COPY ["src/No.Services/No.Gf/No.Gf.Api/No.Gf.Api.csproj", 
"src/No.Services/No.Gf/No.Gf.Api/"]
Error response from daemon: COPY failed: file not found in build context or excluded by .dockerignore: 
stat src\No.Services\No.Gf\No.Gf.Api\No.Gf.Api.csproj: file does not exist

该文件位于路径指向的正确位置..dockerignore中没有排除它.

The file is right where the path points to. It's not exluded in .dockerignore.

我在这里没有选择了吗?

I am out of options here?

第6步是:

Step 6/17 : WORKDIR /src

也许这是在其中添加一个"/src"最多,在步骤7中,它最终是在/src/src/...中寻找文件?

Maybe this is adding one "/src" to much and in step 7 it's finally looking for the file in /src/src/...?

推荐答案

我不知道您的物理目录层次结构,但我想说错误的原因可能是 Dockerfile csproj .在 csproj 位置声明为 src/No.Services/No.Gf/...的情况下, Dockerfile 必须位于同一位置 src 文件夹的级别,以使复制成功.

I don't know your physical directory hierarchies, but I would say that the reason of the error may be the original relative path between the Dockerfile and the csproj. With the csproj location stated like src/No.Services/No.Gf/..., the Dockerfile will have to be at the same level of that src folder, for the copy to be successful.

您能验证一下吗?

((如果您在项目顶部使用典型的 dotnet 解决方案,则在解决方案的根目录中设置 Dockerfile 可能会解决您的错误,因为这样做会尊重文件夹的层次结构.)

(If you are working with a typical dotnet solution on top of the project, setting the Dockerfile in the root of the solution may solve your error, since it will respect the folders' hierarchy.)

关于其他主题:

  • WORKDIR 命令引用容器中的工作目录(

  • The WORKDIR command refers to the working directory in the container (reference), so, I would say that it is not the reason for your error, because it seems that, when copying, the file is not found in its source.

成功复制到容器中后,它可能位于类似 src/src/No.Services/No.Gf/...的目录中复制,在容器内.

When the copy into the container is successful, it will probably be in a directory like src/src/No.Services/No.Gf/..., but this is after copying, inside the container.

这篇关于Docker配置找不到现有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆