Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The command 'cmd /S /C dotnet restore' returned a non-zero code: 1 #247

Closed
sharadrumane opened this issue Apr 6, 2020 · 8 comments
Closed

Comments

@sharadrumane
Copy link

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-1809 AS build-env
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/core/runtime:3.0-nanoserver-1809
WORKDIR /app
COPY --from=build-env /app/out ./
ENTRYPOINT ["dotnet", "piwebapimodule.dll"]


#above is my dockerfile and below is the error i am getting.

Step 4/10 : RUN dotnet restore
---> Running in 2d8bfe25d6ab
C:\Program Files\dotnet\sdk\2.2.207\NuGet.targets(119,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\abcd.csproj]
C:\Program Files\dotnet\sdk\2.2.207\NuGet.targets(119,5): error : No such host is known [C:\app\abcd.csproj]
The command 'cmd /S /C dotnet restore' returned a non-zero code: 1

i am trying to build and push the image on edge device which is a windows based. i am using VS Code as my IDE. when i am linux VM i am able to build and push the image easily but in case of windows VM i am getting above error.

  • i have switch my docker container to windows.
  • i tried deleting .nuget folder my %userprofile% and from C:\User[username].nuget path. but it did not work.
  • i tried skipping the dotnet restore command which is mention in the docker file it also did not work.
@NCarlsonMSFT
Copy link
Member

@sharadrumane The error message you are seeing is indicative of the container being unable to connect to NuGet.org (NuGet/Home#8805)

Are you using a Proxy?
If you just run the SDK image can you use curl to see if a container on your host can access https://api.nuget.org/v3/index.json?

Probably not related but worth noting:
Your SDK image is 2.2 and your runtime image is 3.0, both of which have reached EOL. If feasible you should update to 3.1 or downgrade to 2.1 to be on a supported version.
Similarly, your are using Nano version 1809, which is still in support, but only until next month. So I'd also recommend going up to 1903 (or better yet 1909) to stay on a supported version (assuming your host is compatible).

@sharadrumane
Copy link
Author

@NCarlsonMSFT i am not using any proxy. i am not able to identify whether container is able to access
https://api.nuget.org/v3/index.json. how can i identify it?

@NCarlsonMSFT
Copy link
Member

Start a container from the command line with the command
docker run -it mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1909
The -it will cause it to start an interactive session where you'll be connected to the command line within the container.

Within the container run:
curl https://api.nuget.org/v3/index.json
If everything is working well you should get a json response like:

{
  "version": "3.0.0",
  "resources": [
    {
      "@id": "https://azuresearch-usnc.nuget.org/query",
      "@type": "SearchQueryService",
      "comment": "Query endpoint of NuGet Search service (primary)"
    },
    {
      "@id": "https://azuresearch-ussc.nuget.org/query",
      "@type": "SearchQueryService",
      "comment": "Query endpoint of NuGet Search service (secondary)"
    },
...
  ],
  "@context": {
    "@vocab": "http://schema.nuget.org/services#",
    "comment": "http://www.w3.org/2000/01/rdf-schema#comment"
  }
}

Assuming the call does fail, it would also be worth trying to connect to other sites. For instance:
curl https://github.com
Should return a bunch of html. Knowing if that works will help determine if there is a network issue specific to nuget.org or more general to the container.

@sharadrumane
Copy link
Author

@NCarlsonMSFT by executing above command
curl https://api.nuget.org/v3/index.json

i am getting below error
curl: (6) Could not resolve host: api.nuget.org

i tried curl https://github.com but also got same error curl: (6) Could not resolve host: github.com

i tried running dotnet nuget locals http-cache --clear. but it didnt work

@StruninIhor
Copy link

The same issue in mcr.microsoft.com/dotnet/core/sdk:3.1 image:
sudo docker run -it mcr.microsoft.com/dotnet/core/sdk:3.1
root@83e1ca5c839a:/# curl https://api.nuget.org/v3/index.json
curl: (6) Could not resolve host: api.nuget.org

@NCarlsonMSFT
Copy link
Member

@StruninIhor based on what you are seeing you appear to be having a networking issue with your windows containers. There is an existing issue in the docker repo that appears to have some good troubleshooting steps I would recommend you try: Windows containers can't access the internet. If those steps aren't able to resolve your issue, opening a new issue in that repro will get you connected to the right experts to help you.

@sharadrumane
Copy link
Author

sharadrumane commented Apr 9, 2020

@NCarlsonMSFT I tried the steps mention in the link you provided Windows containers can't access the internet #2760. but it didn't work for me.

@NCarlsonMSFT
Copy link
Member

@sharadrumane then I would advise as your next step opening an issue in that repo. Your issue appears to be a general issue with windows containers and that is the best place to get help for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants