-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
COPY failed: stat /var/lib/docker/tmp/docker-builder492837088/myMicroservice.csproj: no such file or directory #2448
Comments
has there been any update to this? I am having the exact same problem and cannot find the fix for it. |
It looks like this is a generic error that happens when the file isn't found: https://stackoverflow.com/q/32997269. Is it possible the Dockerfile is in a different directory from /cc @MichaelSimons |
Any update on this? I am running into the same error. I have the Dockerfile, myMicroService.csproj and the other files in the 'myMicroservice' folder. |
This issue is waiting on more info from the opener. But from your comment, the extra capital in Normally on Windows case doesn't matter, but Docker by default runs containers in a Linux VM where the file system is case-sensitive. |
I tried out the tutorial on my machine with Docker freshly installed to confirm what I'm thinking. The tutorial works when I follow the steps, but if I rename
Hopefully this solves the issue for you @shaun-rostami, let me know if you're still having problems when the casing is the same. (A zip of your project wouldn't hurt!) Otherwise, I'm going to give @kaisernayan a few more days to get back to us then close the issue. |
Thanks @dagood! Yes the capital S in myMicroService.csproj was the problem. |
Awesome, thanks for confirming. 😄 (I could have been been clearer that what I was doing was simulating the error, and doing the opposite is what would fix your problem, sorry about that.) |
Seems addressed, closing. |
Hello, I solved the issue after working for two days. code of dockerfile.
My update My updated code
|
What worked for me was ridiculous thing. I had to change absolute path |
@ldynia, When using the |
I managed to resolve mine by running the command from the folder above (where I had my solution file). If you look in the folder above, you will see visual studio adds a .dockerignore file there. That gave me the clue that it must be running from that directory. the link at the top of the page helps explains how visual studio runs the docker file https://aka.ms/containerfastmode |
@princeo911 yes, that worked, also we have to move Dockerfile to the root. So the problem boil downs to that if we generate doclerfile using Visual Studio (Right click on project -> Add -> Docker support) then we manually have to copy the file to the root. Ideally, Visual Studio team should fix it. |
As an extension, I than ran into not being able to run the project in visual studio anymore, so I solved it with the following link: tl;dr I added the following to the project file.
|
For me, this ended up being a casing issue for a reference to a project file in my Dockerfile. |
Do this: |
thanks! it's worked |
This solution needs more attention. For me as a beginner it was exactly this problem, Visual Studio Created the file 1 directory deeper as it was supposed. Thank you. |
This happen Visual Studio add docker compose file one level up in Dockerfile dir. that mean The Dockerfile creating to support docker-compose. easy step to resolve use "docker-compose" up to build images else you need to specify path as in above posts. eg "docker build -f .//Dockerfile ." |
It will work if you use COPY ./myMicroservice.csproj myMicroservice/ 100% it will work try it . |
I have VS 2019 Solution with 2 projects: P1 (Standard lib) & P2 (ASP.NET Core exe).
How to fix it? |
vs2019 asp.net core 3.1 docker(linux) - working test #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build FROM build AS publish FROM base AS final docker run -d -p 8000:80 --name runapp webapp |
Im adding my comment for posterity. The issue I had was that visual studio had put the .csproj file too deep in the path inside the Dockerfile
Changed to
|
Will it be fixed at all? |
Generated the docker file of my existing azure function project from the left menu Docker Support. During the build in devops, it's throwing error as : The docker file auto-generated is : FROM mcr.microsoft.com/azure-functions/dotnet:3.0 AS base FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build FROM build AS publish FROM base AS final
|
Q: How to solve docker command work folder are not right ? A: Using the DockerfileContext to set the WorkingDirectory <PropertyGroup>
<DockerfileContext>..\..\..</DockerfileContext>
</PropertyGroup> |
Problem encountered on https://dotnet.microsoft.com/learn/web/aspnet-microservice-tutorial/docker-image
Operating System: windows
Following the tutorial I am on step Create Docker image. I run the command "docker build -t mymicroservice ." from PowerShell. Then I got Copy Failed message that says "COPY failed: stat /var/lib/docker/tmp/docker-builder492837088/myMicroservice.csproj: no such file or directory"
Following is the detail response after the command -
Sending build context to Docker daemon 1.162MB
Step 1/14 : FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
---> 2f7531819f40
Step 2/14 : WORKDIR /app
---> Using cache
---> dfeed7f9bed8
Step 3/14 : FROM microsoft/dotnet:2.2-sdk AS build
---> 81d80198a492
Step 4/14 : WORKDIR /src
---> Using cache
---> fb38cbbb96c6
Step 5/14 : COPY myMicroservice.csproj myMicroservice/
COPY failed: stat /var/lib/docker/tmp/docker-builder492837088/myMicroservice.csproj: no such file or directory
My Docker file content is -
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY myMicroservice.csproj myMicroservice/
RUN dotnet restore myMicroservice/myMicroservice.csproj
WORKDIR /src/myMicroservice
COPY . .
RUN dotnet build myMicroservice.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish myMicroservice.csproj -c Release -o /app
FROM base AS final
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "myMicroservice.dll"]
The text was updated successfully, but these errors were encountered: