Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio with docker file support - no such file or directory

I am new to docker. When I create an empty ASP.NET Core MVC project with linux docker support, Visual Studio generates this Dockerfile:

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY DockerTest/DockerTest.csproj DockerTest/
RUN dotnet restore DockerTest/DockerTest.csproj
COPY . .
WORKDIR /src/DockerTest
RUN dotnet build DockerTest.csproj -c Release -o /app

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

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

When I start PowerShell, change directory and run command

docker build .

i get error - no such file or directory.

Sending build context to Docker daemon  910.8kB
Step 1/16 : FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
 ---> bf6acba27669
Step 2/16 : WORKDIR /app
 ---> Using cache
 ---> a48d00205739
Step 3/16 : EXPOSE 80
 ---> Using cache
 ---> 93b2ba2ff3cc
Step 4/16 : FROM microsoft/dotnet:2.1-sdk AS build
 ---> 9d32878ab9fe
Step 5/16 : WORKDIR /src
 ---> Using cache
 ---> 5c5247716e9f
Step 6/16 : COPY DockerTest/DockerTest.csproj DockerTest/
COPY failed: stat /var/lib/docker/tmp/docker-builder159418839/DockerTest/DockerTest.csproj: no such file or directory
like image 735
Александр Сысоев Avatar asked Sep 06 '18 20:09

Александр Сысоев


People also ask

How do I add Docker compose Yml in Visual Studio?

In the Web API project, again right-click on the project node, and choose Add > Container Orchestrator Support. Choose Docker Compose, and then select the same target OS. In this step, Visual Studio will offer to create a Dockerfile.

Can I run Visual Studio in a Docker container?

The Visual Studio Code Dev Containers extension lets you use a Docker container as a full-featured development environment. It allows you to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set.

How do I run a Docker file in Visual Studio?

Open the project in Visual Studio, and choose one of the following options: Select Docker Support from the Project menu. Right-click the project in Solution Explorer and select Add > Docker Support.


1 Answers

This is my fault. I should run this command from root project directory:

docker build -f "DockerTest/Dockerfile" .
like image 62
Александр Сысоев Avatar answered Sep 28 '22 16:09

Александр Сысоев