问题
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
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/...?
回答1:
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.
来源:https://stackoverflow.com/questions/65634892/docker-configuration-does-not-find-existing-file