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
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.
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.
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.
This is my fault. I should run this command from root project directory:
docker build -f "DockerTest/Dockerfile" .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With