VS2019, created a brand new mvc app with Windows Docker support.
Dockerfile contents (created from template):
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-1809 AS build
WORKDIR /src
COPY ["mvc1.csproj", "mvc1/"]
RUN dotnet restore "mvc1/mvc1.csproj"
COPY . .
WORKDIR "/src/mvc1"
RUN dotnet build "mvc1.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "mvc1.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "mvc1.dll"]
When I execute:
docker build -t mvc1 .
I get the following errors:
C:\Program Files\dotnet\sdk\2.2.401\NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\mvc1\mvc1.csproj] C:\Program Files\dotnet\sdk\2.2.401\NuGet.targets(123,5): error : No such host is known [C:\src\mvc1\mvc1.csproj] The command 'cmd /S /C dotnet restore "mvc1/mvc1.csproj"' returned a non-zero code: 1
EDIT: I've added this line to Dockerfile:
RUN ping google.com
and get:
Step 4/17 : RUN ping google.com
---> Running in 6633175b21a8
Ping request could not find host google.com. Please check the name and try again.
EDIT 2:
So, it turns out when I edit my .csproj file and remove this line:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<!-- REMOVED -->
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.12" />
<!-- REMOVED -->
</ItemGroup>
</Project>
It DOES work. Why is that?
dotnet restore -s https://api.nuget.org/v3/index.json
? – Alex Kovanev