'Docker build failing- The remote name could not be resolved: 'api.nuget.org'
I am following a pluralsight tutorial- "Developing .NET Framework Apps with Docker" but dockerfile given in one of the demo failing for me.
Here is the dockerfile:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 AS builder
WORKDIR /src/PetShop.Api
COPY src/PetShop.Api/PetShop.Api.sln .
COPY src/PetShop.Api/PetShop.Api.Entities/PetShop.Api.Entities.csproj ./PetShop.Api.Entities/
COPY src/PetShop.Api/PetShop.Api.Model/PetShop.Api.Model.csproj ./PetShop.Api.Model/
COPY src/PetShop.Api/PetShop.Api.Products/PetShop.Api.Products.csproj ./PetShop.Api.Products/
COPY src/PetShop.Api/PetShop.Api.Products/packages.config ./PetShop.Api.Products/
RUN nuget restore PetShop.Api.sln -PackagesDirectory packages
COPY src /src
RUN msbuild PetShop.Api.Products/PetShop.Api.Products.csproj /p:Configuration=Release /p:OutputPath=c:/out
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
ENV APP_ROOT=C:\\inetpub\\wwwroot
COPY --from=builder /out/_PublishedWebsites/PetShop.Api.Products ${APP_ROOT}
COPY --from=builder /src/PetShop.Api/packages/Microsoft.Data.SqlClient.SNI.2.1.1/build/net46/Microsoft.Data.SqlClient.SNI.x64.dll ${APP_ROOT}/bin
COPY config/appsettings.json ${APP_ROOT}
COPY config/logging.json ${APP_ROOT}/config/
COPY config/connectionstrings.json ${APP_ROOT}/config/
And here is the output of the docker build command:
PS C:\Users\rg21580\Downloads\docker-dot-net-framework-apps-developing\02\demos\demo3> docker build -t petshop-api ./petshop-api
Sending build context to Docker daemon 94.21kB
Step 1/17 : FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 AS builder
4.8-windowsservercore-ltsc2019: Pulling from dotnet/framework/sdk
4612f6d0b889: Already exists
ba8181afd426: Pull complete
02ca74b83f10: Pull complete
5766b0ca35fc: Pull complete
ee971f2d3cad: Pull complete
8bd0de32312c: Pull complete
d1b79a53055d: Pull complete
b9073913d17e: Pull complete
6cc2f27ce166: Pull complete
835d2914821b: Pull complete
Digest: sha256:d91ffeee472a34f8d7ff717fef54422be2ad87e59478c2e507c59eed8aaaa02e
Status: Downloaded newer image for mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
---> dbbd921bf470
Step 2/17 : WORKDIR /src/PetShop.Api
---> Running in 53096698fe2b
Removing intermediate container 53096698fe2b
---> 0f9d67c78245
Step 3/17 : COPY src/PetShop.Api/PetShop.Api.sln .
---> a119a8190c29
Step 4/17 : COPY src/PetShop.Api/PetShop.Api.Entities/PetShop.Api.Entities.csproj ./PetShop.Api.Entities/
---> 0d25ee5d9c38
Step 5/17 : COPY src/PetShop.Api/PetShop.Api.Model/PetShop.Api.Model.csproj ./PetShop.Api.Model/
---> 35e667754785
Step 6/17 : COPY src/PetShop.Api/PetShop.Api.Products/PetShop.Api.Products.csproj ./PetShop.Api.Products/
---> 35bf8e689d58
Step 7/17 : COPY src/PetShop.Api/PetShop.Api.Products/packages.config ./PetShop.Api.Products/
---> 67128e1c97da
Step 8/17 : RUN nuget restore PetShop.Api.sln -PackagesDirectory packages
---> Running in c09cfa5df43b
MSBuild auto-detection: using msbuild version '17.1.0.7609' from 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin'.
Restoring NuGet package log4net.2.0.12.
Restoring NuGet package Antlr.3.5.0.2.
Unable to find version '3.5.0.2' of package 'Antlr'.
https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The remote name could not be resolved: 'api.nuget.org'
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; nuget restore PetShop.Api.sln -PackagesDirectory packages' returned a non-zero code: 1
I am unable to resolve the error- "https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json. An error occurred while sending the request. The remote name could not be resolved: 'api.nuget.org' " which occurs at command- "RUN nuget restore PetShop.Api.sln -PackagesDirectory packages" of the docker file.Thank you so much in advance.
Solution 1:[1]
If you're sure there isn't a network issue (like a DNS issue), then try this solution:
https://sitecore.stackexchange.com/a/30015/1739
It helped me with the same problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | VadimG |