Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

dockerfile - Docker configuration does not find existing file?

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 srcNo.ServicesNo.GfNo.Gf.ApiNo.Gf.Api.csproj: file does not exist

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

I am out of options here?

Step 6 is:

Step 6/17 : WORKDIR /src

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

Could you please verify this?

(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.)

Regarding the other topics:

  • 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.

  • 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...