Windows container cannot http, but Linux container can

Im running a simple container with a windows aspnet image and executing a curl command. The image run under the Windows container backend in Docker Desktop is not able to make http requests, but the same command works using the Linux container backend. Could someone let me know what could be the problem? I’ve tried suggestions such as changing the dns in the daeomon config to 8.8.8.8 and it does not work.

This is from a windows container (Doesn’t Work)

    PS C:\source\pw> docker run mcr.microsoft.com/dotnet/aspnet:3.1 curl https://api.nuget.org/v3/index.json 
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0     0    0     0    0     0      0      0 --:--:--  0:00:10 --:--:--     0

This is from a linux container (Works)

PS C:\source\PayWeb3> docker run mcr.microsoft.com/dotnet/aspnet:3.1 curl https://api.nuget.org/v3/index.json 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0{
  "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)"
    },
    {
      "@id": "https://azuresearch-usnc.nuget.org/autocomplete",
      "@type": "SearchAutocompleteService",
      "comment": "Autocomplete endpoint of NuGet Search service (primary)"
    },
    {
      "@id": "https://azuresearch-ussc.nuget.org/autocomplete",
      "@type": "SearchAutocompleteService",
      "comment": "Autocomplete endpoint of NuGet Search service (secondary)"
    },
    {
      "@id": "https://azuresearch-usnc.nuget.org/",
      "@type": "SearchGalleryQueryService/3.0.0-rc",
      "comment": "Azure Website based Search Service used by Gallery (primary)"
    },
    {
      "@id": "https://azuresearch-ussc.nuget.org/",
      "@type": "SearchGalleryQueryService/3.0.0-rc",
      "comment": "Azure Website based Search Service used by Gallery (secondary)"
    },
    {
      "@id": "https://api.nuget.org/v3/registration5-semver1/",
      "@type": "RegistrationsBaseUrl",
      "comment": "Base URL of Azure storage where NuGet package registration info is stored"
    },
    {
      "@id": "https://api.nuget.org/v3-flatcontainer/",
      "@type": "PackageBaseAddress/3.0.0",
      "comment": "Base URL of where NuGet packages are stored, in the format https://api.nuget.org/v3-flatcontainer/{id-lower}/{version-lower}/{id-lower}.{version-lower}.nupkg"
    },
    {
      "@id": "https://www.nuget.org/api/v2",
      "@type": "LegacyGallery"
    },
    {
      "@id": "https://www.nuget.org/api/v2",
      "@type": "LegacyGallery/2.0.0"
    },
    {
      "@id": "https://www.nuget.org/api/v2/package",
      "@type": "PackagePublish/2.0.0"
    },
    {
      "@id": "https://www.nuget.org/api/v2/symbolpackage",
      "@type": "SymbolPackagePublish/4.9.0",
      "comment": "The gallery symbol publish endpoint."
    },
    {
      "@id": "https://azuresearch-usnc.nuget.org/query",
      "@type": "SearchQueryService/3.0.0-rc",
      "comment": "Query endpoint of NuGet Search service (primary) used by RC clients"
    },
    {
      "@id": "https://azuresearch-ussc.nuget.org/query",
      "@type": "SearchQueryService/3.0.0-rc",
      "comment": "Query endpoint of NuGet Search service (secondary) used by RC clients"
    },
    {
      "@id": "https://azuresearch-usnc.nuget.org/query",
      "@type": "SearchQueryService/3.5.0",
      "comment": "Query endpoint of NuGet Search service (primary) that supports package type filtering"
    },
    {
      "@id": "https://azuresearch-ussc.nuget.org/query",
      "@type": "SearchQueryService/3.5.0",
      "comment": "Query endpoint of NuGet Search service (secondary) that supports package type filtering"
    },
    {
      "@id": "https://azuresearch-usnc.nuget.org/autocomplete",
      "@type": "SearchAutocompleteService/3.0.0-rc",
      "comment": "Autocomplete endpoint of NuGet Search service (primary) used by RC clients"
    },
    {
      "@id": "https://azuresearch-ussc.nuget.org/autocomplete",
      "@type": "SearchAutocompleteService/3.0.0-rc",
      "comment": "Autocomplete endpoint of NuGet Search service (secondary) used by RC clients"
    },
    {
      "@id": "https://azuresearch-usnc.nuget.org/autocomplete",
      "@type": "SearchAutocompleteService/3.5.0",
      "comment": "Autocomplete endpoint of NuGet Search service (primary) that supports package type filtering"
    },
    {
      "@id": "https://azuresearch-ussc.nuget.org/autocomplete",
      "@type": "SearchAutocompleteService/3.5.0",
      "comment": "Autocomplete endpoint of NuGet Search service (secondary) that supports package type filtering"
    },
    {
      "@id": "https://api.nuget.org/v3/registration5-semver1/",
      "@type": "RegistrationsBaseUrl/3.0.0-rc",
      "comment": "Base URL of Azure storage where NuGet package registration info is stored used by RC clients. This base URL does not include SemVer 2.0.0 packages."
    },
    {
      "@id": "https://www.nuget.org/packages/{id}/{version}/ReportAbuse",
      "@type": "ReportAbuseUriTemplate/3.0.0-rc",
      "comment": "URI template used by NuGet Client to construct Report Abuse URL for packages used by RC clients"
    },
    {
      "@id": "https://api.nuget.org/v3/registration5-semver1/{id-lower}/index.json",
      "@type": "PackageDisplayMetadataUriTemplate/3.0.0-rc",
      "comment": "URI template used by NuGet Client to construct display metadata for Packages using ID"
    },
    {
      "@id": "https://api.nuget.org/v3/registration5-semver1/{id-lower}/{version-lower}.json",
      "@type": "PackageVersionDisplayMetadataUriTemplate/3.0.0-rc",
      "comment": "URI template used by NuGet Client to construct display metadata for Packages using ID, Version"
    },
    {
      "@id": "https://azuresearch-usnc.nuget.org/query",
      "@type": "SearchQueryService/3.0.0-beta",
      "comment": "Query endpoint of NuGet Search service (primary) used by beta clients"
    },
    {
      "@id": "https://azuresearch-ussc.nuget.org/query",
      "@type": "SearchQueryService/3.0.0-beta",
      "comment": "Query endpoint of NuGet Search service (secondary) used by beta clients"
    },
    {
      "@id": "https://azuresearch-usnc.nuget.org/autocomplete",
      "@type": "SearchAutocompleteService/3.0.0-beta",
      "comment": "Autocomplete endpoint of NuGet Search service (primary) used by beta clients"
    },
    {
      "@id": "https://azuresearch-ussc.nuget.org/autocomplete",
      "@type": "SearchAutocompleteService/3.0.0-beta",
      "comment": "Autocomplete endpoint of NuGet Search service (secondary) used by beta clients"
    },
    {
      "@id": "https://api.nuget.org/v3/registration5-semver1/",
      "@type": "RegistrationsBaseUrl/3.0.0-beta",
      "comment": "Base URL of Azure storage where NuGet package registration info is stored used by Beta clients. This base URL does not include SemVer 2.0.0 packages."
    },
    {
      "@id": "https://www.nuget.org/packages/{id}/{version}/ReportAbuse",
      "@type": "ReportAbuseUriTemplate/3.0.0-beta",
      "comment": "URI template used by NuGet Client to construct Report Abuse URL for packages"
    },
    {
      "@id": "https://www.nuget.org/packages/{id}/{version}?_src=template",
      "@type": "PackageDetailsUriTemplate/5.1.0",
      "comment": "URI template used by NuGet Client to construct details URL for packages"
    },
    {
      "@id": "https://api.nuget.org/v3/registration5-gz-semver1/",
      "@type": "RegistrationsBaseUrl/3.4.0",
      "comment": "Base URL of Azure storage where NuGet package registration info is stored in GZIP format. This base URL does not include SemVer 2.0.0 packages."
    },
    {
      "@id": "https://api.nuget.org/v3/registration5-gz-semver2/",
      "@type": "RegistrationsBaseUrl/3.6.0",
      "comment": "Base URL of Azure storage where NuGet package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
    },
    {
      "@id": "https://api.nuget.org/v3/registration5-gz-semver2/",
      "@type": "RegistrationsBaseUrl/Versioned",
      "clientVersion": "4.3.0-alpha",
      "comment": "Base URL of Azure storage where NuGet package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
    },
    {
      "@id": "https://api.nuget.org/v3-index/repository-signatures/4.7.0/index.json",
      "@type": "RepositorySignatures/4.7.0",
      "comment": "The endpoint for discovering information about this package source's repository signatures."
    },
    {
      "@id": "https://api.nuget.org/v3-index/repository-signatures/5.0.0/index.json",
      "@type": "RepositorySignatures/5.0.0",
      "comment": "The endpoint for discovering information about this package source's repository signatures."
    },
    {
      "@id": "https://api.nuget.org/v3/catalog0/index.json",
      "@type": "Catalog/3.0.0",
      "comment": "Index of the NuGet package catalog."
    }
  ],
  "@context": {
    "@vocab": "http://schema.nuget.org/services#",
    "comment": "http://www.w3.org/2000/01/rdf-schema#comment"
  }
100  8543  100  8543    0     0  43365      0 --:--:-- --:--:-- --:--:-- 43365

@dfrissell80 were you able to resolve this issue ? I am facing same exact issue :frowning:

Does other commands work, like ping? This seems weird as the command seems to run but no progress, right? I’m assuming the image is starting fine, and it’s just the connectivity that might be broken. It would help to know if ping to anything (www.google.com, for example) works or not.

@vrapolinario thank you for your response.
Here is what I think is happening

My docker daemon is executing each command (i.e. docker build .) - at this point not sure if container is already spun up ?

it tries to execute dotnet restore command

seems it is not able to either resolve dns / or able to reach to internet

My Environment:
Windows 10 Pro (OS)
Docker for Desktop
target framework .net core / .net6.0

Thank you !

Here is my test result (similar to one from previous post)(mode: windows container)

What I usually do when trying to troubleshoot why something breaks in docker build is to use docker run -it to the base image and run the commands on the docker file manually. Again, it’s hard to help here without knowing if this is a curl issue or an overall network issue.

Got you, so I ran base image , and from container (windows) I ran ping command and message says “could not find host google.com

So, your issue is that the container is not able to reach the internet. Have you changed anything? What is the environment? Is it Windows 10/11 or Windows Server? Also, I’d not change the networking config as you mentioned (DNS setting on the daemon) unless you really need to.

One more thing: the curl command in Windows should be slightly different than Linux:

curl.exe https://api.nuget.org/v3/index.json -o index.json

Hello @vrapolinario

Finally the issue was resolved. It was my ANTIVIRUS, who was blocking my internal traffic between my container and my host (not sure exactly how?)

As soon as I un-installed my antivirus, restarted my machine , and ran docker build command , worked like a charm;

Thanks a ton for providing input , this was very helpful !!!

1 Like

I’m glad you were able to figure this out. Can you please share which AV it was so we know this might happen in the future (and maybe I can let the Windows containers product team know about this).

Hello @vrapolinario ,

This was McAfee AV.

Thank you !

1 Like