core icon indicating copy to clipboard operation
core copied to clipboard

COPY failed: stat /var/lib/docker/tmp/docker-builder549405077/WebApplication1/WebApplication1.csproj: no such file or directory

Open sanjeev02saraswat opened this issue 7 years ago • 10 comments

Issue Title

COPY failed: stat /var/lib/docker/tmp/docker-builder549405077/WebApplication1/WebApplication1.csproj: no such file or directory

General

I have created one simple .net core web app and created docker file for the same.Below is the docker file content:

**FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base WORKDIR /app EXPOSE 80 EXPOSE 443

FROM microsoft/dotnet:2.2-sdk AS build WORKDIR /src COPY ["WebApplication1/WebApplication1.csproj", "WebApplication1/"] RUN dotnet restore "WebApplication1/WebApplication1.csproj" COPY . . WORKDIR "/src/WebApplication1" RUN dotnet build "WebApplication1.csproj" -c Release -o /app

FROM build AS publish RUN dotnet publish "WebApplication1.csproj" -c Release -o /app

FROM base AS final WORKDIR /app COPY --from=publish /app . ENTRYPOINT ["dotnet", "WebApplication1.dll"]**

I have run command: docker build -t webapp -f Dockerfile . for creating docker image.

Log

sanjeev02saraswat avatar Nov 21 '19 06:11 sanjeev02saraswat

CC @shirhatti @MichaelSimons

scalablecory avatar Dec 07 '19 02:12 scalablecory

I faced the same issue and fixed it. Just replace COPY ["WebApplication1/WebApplication1.csproj", "WebApplication1/"] with COPY . WebApp1/ @sanjeev02saraswat

vasilymarchenko avatar Dec 21 '19 20:12 vasilymarchenko

@sanjeev02saraswat, it looks like the reason COPY is failing is because the source path does not exist in your Docker build context. Your docker build command is passing in c:\users\sanjeev.x.sarasat\source\repos\WebApplication1\WebApplication1 as the build context directory which is the last parameter (e.g. .). To get this to work correctly you will either need to change your build context directory to c:\users\sanjeev.x.sarasat\source\repos\WebApplication1 or change the COPY source path to WebApplication1.csproj.

MichaelSimons avatar Jan 03 '20 15:01 MichaelSimons

@sanjeev02saraswat, I suggest you to cd C:\Users\sanjeev.x.saraswat\source\repos\WebApplication1 and then type docker build -f WebApplication1/DockerFile -t webapp . (make sure docker file in this directory C:\Users\sanjeev.x.saraswat\source\repos\WebApplication1\WebApplication1)

alihangokdemir avatar Jan 23 '20 22:01 alihangokdemir

@sanjeev02saraswat, I suggest you to cd C:\Users\sanjeev.x.saraswat\source\repos\WebApplication1 and then type docker build -f WebApplication1/DockerFile -t webapp . (make sure docker file in this directory C:\Users\sanjeev.x.saraswat\source\repos\WebApplication1\WebApplication1)

That worked for me, thank you so much! docker build -f AppName/DockerFile -t webapp .

orassr avatar Apr 12 '20 02:04 orassr

I had to use the following command to start the build:

docker build .

TadejTastro avatar May 05 '20 11:05 TadejTastro

Doing this: docker build -f Dockerfile .. should resolve the issue. Reference: https://docs.microsoft.com/en-us/visualstudio/containers/container-build?view=vs-2019#building-from-the-command-line

kwameg-a avatar May 24 '20 12:05 kwameg-a

I have VS 2019 Solution with 2 projects: P1 (Standard lib) & P2 (ASP.NET Core exe). P2 contains a Dockerfile. I have copied the Docker file to up folder, tried to build the docker running the cmd :

docker build -f Dockerfile .. Sending build context to Docker daemon 3.056GB Step 1/18 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base ---> 5d7a95ed1660 Step 2/18 : WORKDIR /app ---> Using cache ---> 6e8271ae3df9 Step 3/18 : EXPOSE 80 ---> Using cache ---> e45066aa184b Step 4/18 : EXPOSE 443 ---> Using cache ---> 0bbce5ed4c30 Step 5/18 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build ---> 925a86b607a3 Step 6/18 : WORKDIR /src ---> Using cache ---> e4af901c8e34 Step 7/18 : COPY ["PropMan/PropMan.csproj", "PropMan/"] COPY failed: stat /var/lib/docker/tmp/docker-builder808977273/PropMan/PropMan.csproj: no such file or directory PS D:\MyProjects\PM2020\PMan>

How to fix it?

ZedZipDev avatar Jul 27 '20 17:07 ZedZipDev

I have VS 2019 Solution with 2 projects: P1 (Standard lib) & P2 (ASP.NET Core exe). P2 contains a Dockerfile. I have copied the Docker file to up folder, tried to build the docker running the cmd :

docker build -f Dockerfile .. Sending build context to Docker daemon 3.056GB Step 1/18 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base ---> 5d7a95ed1660 Step 2/18 : WORKDIR /app ---> Using cache ---> 6e8271ae3df9 Step 3/18 : EXPOSE 80 ---> Using cache ---> e45066aa184b Step 4/18 : EXPOSE 443 ---> Using cache ---> 0bbce5ed4c30 Step 5/18 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build ---> 925a86b607a3 Step 6/18 : WORKDIR /src ---> Using cache ---> e4af901c8e34 Step 7/18 : COPY ["PropMan/PropMan.csproj", "PropMan/"] COPY failed: stat /var/lib/docker/tmp/docker-builder808977273/PropMan/PropMan.csproj: no such file or directory PS D:\MyProjects\PM2020\PMan>

How to fix it?

tried @kwameg-a suggestion and that worked for me. docker build -t webapi -f Dockerfile ..

kvishalv avatar Aug 12 '20 17:08 kvishalv

Closing, looks like this was answered.

scalablecory avatar Nov 22 '21 19:11 scalablecory