1
votes

I've tried to build my Docker image and this is what happens when I build it. Is there any wrong setting?

2>C:\Program Files\dotnet\sdk\2.2.100\NuGet.targets(114,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\DockNetMicro\DockNetMicro.csproj] 2>C:\Program Files\dotnet\sdk\2.2.100\NuGet.targets(114,5): error : No such host is known [C:\src\DockNetMicro\DockNetMicro.csproj] 2>The command 'cmd /S /C dotnet restore "DockNetMicro/DockNetMicro.csproj"' returned a non-zero code: 1 2>C:\Users\rizka.hasmulyawan.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.0.2105168\build\Container.targets(159,5): error MSB3073: The command "docker build -t "docknetmicro" -f "e:\work\note\netcoretest\docknetmicro\docknetmicro\dockerfile" --label "com.microsoft.created-by=visual-studio" ".."" exited with code 1. 2>Done building project "DockNetMicro.csproj" -- FAILED.

this is my Dockerfile

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

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

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

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

2
Please add some code so one can help you.raju_odi

2 Answers

0
votes

This is a known frequent bug. The problem you are having is that you are not able to restore packages from nuget inside your container.

I would suggest these to resolve your error:

  1. using a different version of that image which might have a different version of dotnet runtime. Sometimes different versions of dotnet are able to restore packages.
  2. build and publish everything in your local host system and copy that folder to your container. just use the base image as the destination. Keep the local output directory of dlls as your source.