vscode-dev-containers icon indicating copy to clipboard operation
vscode-dev-containers copied to clipboard

Cannot Resolve Host on api.nuget.org From Within Docker-From-Docker-Compose Container on WSL

Open RLashofRegas opened this issue 3 years ago • 5 comments

  • VSCode Version:1.67.2
  • Local OS Version: Windows 10 21H2 Build 19044.1708, running WSL v2 Ubuntu 20.04
  • Local chip architecture: x86
  • Reproduces in: Remote - Containers
  • Name of Dev Container Definition with Issue: Docker From Docker Compose

Steps to Reproduce:

  1. Open Ubuntu shell via WSL v2
  2. Create new empty directory - mkdir test
  3. Open VS Code in empty directory - code test
  4. Use command palette to invoke "Remote-Containers: Add Development Container Configuration Files..." command
  5. Select "Docker from Docker Compose" container definition and accept all defaults
  6. Use command palette to invoke "Remote-Containers: Reopen in Container" action
  7. Open bash shell and run curl api.nuget.org response is:

curl: (6) Could not resolve host: api.nuget.org

Additional Notes:

  • I tried the same steps as above but with the "Docker From Docker" container definition (i.e. no compose) and I did not get the same error
  • This may be related, but seems slightly different from the issue I opened earlier today: #1470
  • when comparing between the Docker From Docker vs the Docker From Docker Compose containers, /etc/hosts, /etc/nsswitch.conf, and /etc/resolv.conf all match
  • I tested that curl google.com works:
301 Moved

301 Moved

The document has moved here.
  • I installed host and dnsutils, results are as follows: $ host -v api.nuget.org >

Trying "api.nuget.org" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33132 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION: ;api.nuget.org. IN A

Received 31 bytes from 127.0.0.11#53 in 10 ms Trying "api.nuget.org" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22994 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION: ;api.nuget.org. IN AAAA

Received 31 bytes from 127.0.0.11#53 in 0 ms Trying "api.nuget.org" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18793 ;; flags: qr rd; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION: ;api.nuget.org. IN MX

;; ANSWER SECTION: api.nuget.org. 0 IN CNAME nugetapiprod.trafficmanager.net. nugetapiprod.trafficmanager.net. 0 IN CNAME apiprod-mscdn.azureedge.net. apiprod-mscdn.azureedge.net. 0 IN CNAME apiprod-mscdn.afd.azureedge.net. apiprod-mscdn.afd.azureedge.net. 0 IN CNAME star-azureedge-prod.trafficmanager.net. star-azureedge-prod.trafficmanager.net. 0 IN CNAME dual.part-0043.t-0009.t-msedge.net. dual.part-0043.t-0009.t-msedge.net. 0 IN CNAME part-0043.t-0009.t-msedge.net.

Received 239 bytes from 127.0.0.11#53 in 60 ms


$ nslookup -debug api.nuget.org >

Server: 127.0.0.11 Address: 127.0.0.11#53


QUESTIONS:
    api.nuget.org, type = A, class = IN
ANSWERS:
AUTHORITY RECORDS:
ADDITIONAL RECORDS:

Non-authoritative answer:

QUESTIONS:
    api.nuget.org, type = AAAA, class = IN
ANSWERS:
AUTHORITY RECORDS:
ADDITIONAL RECORDS:

*** Can't find api.nuget.org: No answer

RLashofRegas avatar May 25 '22 01:05 RLashofRegas

Two more notes that may be relevant:

  1. $ curl api.nuget.org works from the WSL bash shell (i.e. not inside the dev container.
  2. I am not able to reproduce this issue when running Docker for Windows using Hyper-V driver (haven't checked what happens if I switch Windows Docker to use WSL driver)

RLashofRegas avatar May 25 '22 02:05 RLashofRegas

same for me. Any news? Thanks

danieledefrancesco avatar Aug 11 '22 12:08 danieledefrancesco

Facing same issue with windows container, when trying to ping from within windows container it is not able to resolve dns

image

**note above image is running command from container in -it mode

janivimal avatar Oct 03 '22 20:10 janivimal

Same for me, also. Any news?

Livius90 avatar Nov 27 '22 03:11 Livius90

@Livius90 , finally discovered there was a certificate issue, since I was behind firewall and it was blocking my requests. How this issue was resolved was by using a cert in container and it then used this cert to connect/download nugets and finally it was able to resolve this.

janivimal avatar Nov 28 '22 18:11 janivimal