visual studio docker error: NU1301: Unable to > load the service index for source

Teymur Hajiyev 35 Reputation points
2023-06-17T07:23:18.7533333+00:00

Dear All.

Can not containerize .NET Web Api project in Visual Studio 2022. Below is my dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base WORKDIR /app EXPOSE 80 FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build WORKDIR /src COPY ["API.Authentication/API.Authentication.csproj", "API.Authentication/"] COPY ["API.Core/API.Core.csproj", "API.Core/"] COPY ["Infrastructure.Persistence/Infrastructure.Persistence.csproj", "Infrastructure.Persistence/"] COPY ["Core.Application/Core.Application.csproj", "Core.Application/"] COPY ["Core.Domain/Core.Domain.csproj", "Core.Domain/"] COPY ["Infrastructure.CustomAttributes/Infrastructure.CustomAttributes.csproj", "Infrastructure.CustomAttributes/"] COPY ["Shared.Kernel/Shared.Kernel.csproj", "Shared.Kernel/"] COPY ["Shared.ViewModel/Shared.ViewModel.csproj", "Shared.ViewModel/"] RUN dotnet restore "API.Authentication/API.Authentication.csproj" COPY . . WORKDIR "/src/API.Authentication" RUN dotnet build "API.Authentication.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "API.Authentication.csproj" -c Release -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "API.Authentication.dll"]

Receiving below error:

Step 14/23 : RUN dotnet restore "API.Authentication/API.Authentication.csproj" ---> Running in 36ddc34cd2a1 Determining projects to restore... C:\src\Shared.Kernel\Shared.Kernel.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\API.Authentication\API.Authentication.csproj]

Thanks in advance.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,731 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,420 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Manu Philip 17,021 Reputation points MVP
    2023-06-19T03:04:06.7733333+00:00

    This looks like a docker desktop dns config issue

    Adding DNS Server into Docker Engine may solve the problem as below:

    Step:-

    • Open Docker Desktop application
    • Go to Setting
    • Go to Docker Engine
    • Add DNS tag in setting configuration as below

    "dns":["1.1.1.1","8.8.8.8"],


    --please don't forget to upvote and Accept as answer if the reply is helpful--

    15 people found this answer helpful.

  2. FAIGAN, Joel 5 Reputation points
    2023-11-04T17:59:40.0033333+00:00

    This link corrected my problem. I needed to capture my ZScaler certificate and provide it to Docker.

    0 comments No comments