Skip to content

getaddrinfo in Windows docker container #15889

Closed

Description

@StefanScherer

Description of problem:
Running npm install fails inside a Windows Docker container with Error: getaddrinfo ENOENT registry.npmjs.org:443. Reducing the problem to the core it seems that getaddrinfo does not handle AI_ADDRCONFIG correctly.

docker version:

Client:
 Version:      1.9.0-dev
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   4376380
 Built:        Wed Aug 19 14:59:24 UTC 2015
 OS/Arch:      windows/amd64

Server:
 Version:      1.9.0-dev
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   4376380
 Built:        Wed Aug 19 14:59:24 UTC 2015
 OS/Arch:      windows/amd64

docker info:

Containers: 37
Images: 89
Storage Driver: windowsfilter
 Windows:
Execution Driver: Windows 1854 1.9.0-dev 4376380
Logging Driver: json-file
Kernel Version: 10.0 10514 (10514.0.amd64fre.th2_release.150808-1529)
Operating System: Windows Server 2016 Technical Preview 3
CPUs: 2
Total Memory: 4 GiB
Name: VAGRANT-2016
ID: 3A6C:S32I:LEC6:YQJB:7PIZ:OK6F:5DEX:X4EI:4SQV:U6MJ:FOTF:W2KN
Debug mode (server): true
File Descriptors: -1
Goroutines: 14
System Time: 2015-08-22T12:59:06.9061205-07:00
EventsListeners: 0
Init SHA1:
Init Path: C:\Windows\System32\docker.exe
Docker Root Dir: C:\ProgramData\docker

uname -a:

MSYS_NT-10.0 vagrant-2016 2.1.0(0.288/5/3) 2015-06-28 18:57 x86_64 Msys

Environment details (AWS, VirtualBox, physical, etc.):
Windows 2016 TP3 running in VMware Fusion 7.1.2 on a Mac OSX 10.10.4

How reproducible:

Steps to Reproduce:

  1. After a long investigation in npm install and other http requests fail with getaddrinfo ENOENT in a Windows Docker container nodejs/node#2578 I've built a static windows binary to do some test with the getaddrinfo function.
  2. Create a docker container image with that binary

Dockerfile:

FROM windowsservercore

RUN powershell -Command "wget -Uri https://github.com/StefanScherer/win-getaddrinfo/releases/download/1.0.5/getaddrinfo.exe -OutFile getaddrinfo.exe -UseBasicParsing"

CMD [ "getaddrinfo" ]

Run

docker build -t getaddrinfo .
  1. Run a container and run the test binary without and with the AI_ADDRCONFIG flag
docker run -it getaddrinfo cmd
C:\Windows\system32>getaddrinfo registry.npmjs.org 80 0
C:\Windows\system32>getaddrinfo registry.npmjs.org 80 AI_ADDRCONFIG

Actual Results:
Only without the AI_ADDRCONFIG flag the DNS lookup works.

C:\Windows\system32>getaddrinfo.exe registry.npmjs.org 0 0
Calling getaddrinfo with following parameters:
        nodename = registry.npmjs.org
        servname (or port) = 0
        hints.ai_flags = 0x0

getaddrinfo returned success
getaddrinfo response 1
        Flags: 0x0
        Family: AF_INET (IPv4)
        IPv4 address 185.31.17.162
        Socket type: SOCK_STREAM (stream)
        Protocol: IPPROTO_TCP (TCP)
        Length of this sockaddr: 16
        Canonical name: (null)

C:\Windows\system32>getaddrinfo.exe registry.npmjs.org 0 AI_ADDRCONFIG
Calling getaddrinfo with following parameters:
        nodename = registry.npmjs.org
        servname (or port) = 0
        hints.ai_flags = 0x400

getaddrinfo failed with error: 11004

C:\Windows\system32>ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : vagrant-2016
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : localdomain

Ethernet adapter vEthernet (Virtual Switch-efde3b0e095f5d721e3324ea41803b460e9cb3fc0e37a644c12647da9e7da541-0):

   Connection-specific DNS Suffix  . : localdomain
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #3
   Physical Address. . . . . . . . . : 00-15-5D-00-00-01
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::a09f:38f0:1c94:bc6%20(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.16.0.2(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.240.0.0
   Default Gateway . . . . . . . . . : 172.16.0.1
   DNS Servers . . . . . . . . . . . : 192.168.254.2
   NetBIOS over Tcpip. . . . . . . . : Disabled

Expected Results:
The getaddrinfo should lookup the IP address in both cases as the Docker container has an IPv4 address 172.16.0.2. See MSDN getaddrinfo AI_ADDRCONFIG for details.

Additional info:

The source to the static binary can be found in this public repo: https://github.com/StefanScherer/win-getaddrinfo
This is a slightly modified version of the code example from the MSDN getaddrinfo description.

/cc @swernli @jhowardmsft

Activity

  1. lowenna commented on Aug 27, 2015

    @lowenna
    Member

    Short answer - not sure. It'll be an issue in the networking stack in Windows rather than docker as such. I will ask if it's known and file an internal bug if necessary/not by design.

  2. StefanScherer commented on Aug 28, 2015

    @StefanScherer
    ContributorAuthor

    Some further investigation a call to Get-NetAdapter does not show the Ethernet Adapter #3, but the both of the host.

    Running inside a Windows Container:

    PS C:\Windows\system32> ipconfig /all
    
    Windows IP Configuration
    
       Host Name . . . . . . . . . . . . : vagrant-2016
       Primary Dns Suffix  . . . . . . . :
       Node Type . . . . . . . . . . . . : Hybrid
       IP Routing Enabled. . . . . . . . : No
       WINS Proxy Enabled. . . . . . . . : No
       DNS Suffix Search List. . . . . . : localdomain
    
    Ethernet adapter vEthernet (Virtual Switch-9779fbd93fd4047944ce47d9b246900c87c867e6451ed223ac6cfe91583d4063-0):
    
       Connection-specific DNS Suffix  . : localdomain
       Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #3
       Physical Address. . . . . . . . . : 00-15-5D-00-00-01
       DHCP Enabled. . . . . . . . . . . : Yes
       Autoconfiguration Enabled . . . . : Yes
       Link-local IPv6 Address . . . . . : fe80::49ce:5218:c494:5e09%20(Preferred)
       IPv4 Address. . . . . . . . . . . : 172.16.0.2(Preferred)
       Subnet Mask . . . . . . . . . . . : 255.240.0.0
       Default Gateway . . . . . . . . . : 172.16.0.1
       DNS Servers . . . . . . . . . . . : 192.168.254.2
       NetBIOS over Tcpip. . . . . . . . : Disabled
    
    PS C:\Windows\system32> get-netadapter
    
    Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
    ----                      --------------------                    ------- ------       ----------             ---------
                              Hyper-V Virtual Ethernet Adapter #2                                                     0 bps
                              vmxnet3 Ethernet Adapter                                                                0 bps
    

    Running on the Win2016TP Host:

    PS Z:\resources\dockerfiles-windows> get-netadapter
    
    Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
    ----                      --------------------                    ------- ------       ----------             ---------
    vEthernet (Virtual Swi... Hyper-V Virtual Ethernet Adapter #2          10 Up           00-15-5D-00-00-00        10 Gbps
    Ethernet 2                vmxnet3 Ethernet Adapter                      6 Up           00-0C-29-7C-26-C1        10 Gbps
    
    
    PS Z:\resources\dockerfiles-windows> ipconfig /all
    
    Windows IP Configuration
    
       Host Name . . . . . . . . . . . . : vagrant-2016
       Primary Dns Suffix  . . . . . . . :
       Node Type . . . . . . . . . . . . : Hybrid
       IP Routing Enabled. . . . . . . . : No
       WINS Proxy Enabled. . . . . . . . : No
       DNS Suffix Search List. . . . . . : localdomain
    
    Ethernet adapter Ethernet 2:
    
       Connection-specific DNS Suffix  . : localdomain
       Description . . . . . . . . . . . : vmxnet3 Ethernet Adapter
       Physical Address. . . . . . . . . : 00-0C-29-7C-26-C1
       DHCP Enabled. . . . . . . . . . . : Yes
       Autoconfiguration Enabled . . . . : Yes
       Link-local IPv6 Address . . . . . : fe80::94fe:d97a:980b:f687%6(Preferred)
       IPv4 Address. . . . . . . . . . . : 192.168.254.134(Preferred)
       Subnet Mask . . . . . . . . . . . : 255.255.255.0
       Lease Obtained. . . . . . . . . . : Friday, August 28, 2015 10:07:30 AM
       Lease Expires . . . . . . . . . . : Friday, August 28, 2015 10:52:30 AM
       Default Gateway . . . . . . . . . : 192.168.254.2
       DHCP Server . . . . . . . . . . . : 192.168.254.254
       DHCPv6 IAID . . . . . . . . . . . : 100666409
       DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1D-67-BF-6D-00-0C-29-ED-DE-30
       DNS Servers . . . . . . . . . . . : 192.168.254.2
       Primary WINS Server . . . . . . . : 192.168.254.2
       NetBIOS over Tcpip. . . . . . . . : Enabled
    
    Ethernet adapter vEthernet (Virtual Switch):
    
       Connection-specific DNS Suffix  . :
       Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
       Physical Address. . . . . . . . . : 00-15-5D-00-00-00
       DHCP Enabled. . . . . . . . . . . : No
       Autoconfiguration Enabled . . . . : Yes
       Link-local IPv6 Address . . . . . : fe80::ec44:5a76:2916:d500%10(Preferred)
       IPv4 Address. . . . . . . . . . . : 172.16.0.1(Preferred)
       Subnet Mask . . . . . . . . . . . : 255.240.0.0
       Default Gateway . . . . . . . . . :
       DHCPv6 IAID . . . . . . . . . . . : 335549789
       DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1D-67-BF-6D-00-0C-29-ED-DE-30
       DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                           fec0:0:0:ffff::2%1
                                           fec0:0:0:ffff::3%1
       NetBIOS over Tcpip. . . . . . . . : Enabled
    
    Tunnel adapter isatap.localdomain:
    
       Media State . . . . . . . . . . . : Media disconnected
       Connection-specific DNS Suffix  . : localdomain
       Description . . . . . . . . . . . : Microsoft ISATAP Adapter
       Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
       DHCP Enabled. . . . . . . . . . . : No
       Autoconfiguration Enabled . . . . : Yes
    
    Tunnel adapter isatap.{CC8CCE2C-EF56-49B4-AB41-7E626058E44B}:
    
       Media State . . . . . . . . . . . : Media disconnected
       Connection-specific DNS Suffix  . :
       Description . . . . . . . . . . . : Microsoft ISATAP Adapter #3
       Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
       DHCP Enabled. . . . . . . . . . . : No
       Autoconfiguration Enabled . . . . : Yes
    
  3. lowenna commented on Sep 2, 2015

    @lowenna
    Member

    Being tracked internally by 3719364

  4. friism commented on Jan 13, 2016

    @friism
    Contributor

    @jhowardmsft do you have a status on 3719364? Do you know if it was fixed in TP4?

  5. StefanScherer commented on Jan 13, 2016

    @StefanScherer
    ContributorAuthor

    AFAIK this is still an issue, I still patch the node.exe and tested it once with TP4 without the patch.

  6. lowenna commented on Jan 13, 2016

    @lowenna
    Member

    The bug is still showing as open and active internally.

  7. friism commented on Jan 13, 2016

    @friism
    Contributor

    Thanks @jhowardmsft!

  8. hoho commented on Feb 8, 2016

    @hoho

    I have the same issue. Are there known workarounds?

  9. StefanScherer commented on Feb 8, 2016

    @StefanScherer
    ContributorAuthor

    @hoho for Node.js in a Windows Container I still use this workaround patching the binary.

  10. dwickern commented on Mar 1, 2016

    @dwickern

    I had the same issue with this dockerfile:

    FROM windowsservercore
    
    # install chocolatey
    RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" \
      && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
    
    RUN choco install nodejs.install --yes --version 5.7.0
    
    # bower install fails without this workaround (thanks @StefanScherer!)
    RUN powershell -Command \
      wget -Uri https://github.com/StefanScherer/win-patch-iojs/releases/download/1.0.9/patchiojs.exe -OutFile patchiojs.exe -UseBasicParsing ; \
      patchiojs.exe 'C:/Program Files/nodejs/node.exe' ; \
      Remove-Item -Path patchiojs.exe
    
    RUN npm install --global --no-optional bower
    
  11. njappboy commented on Mar 22, 2016

    @njappboy

    @dwickern is the chocolatey install working for you? Seems to fail when I'm performing a docker build. The actual install RUN doesn't actually error or send anything to STDERR, but my subsequent RUN choco install -y commands all fail to find the choco runtime because the installation step never actually installs chocolatey. I verified by attaching to the container after the chocolatey install but before any choco install attempts are made. There is no chocolatey folder in the C:\ProgramData folder. Any ideas?

  12. dwickern commented on Mar 22, 2016

    @dwickern

    @njappboy that dockerfile worked for me on Windows 2016 TP4. You could try installing chocolatey interactively: start a container with docker run -it --rm windowsservercore cmd then run the first command.

  13. njappboy commented on Mar 23, 2016

    @njappboy

    @dwickern it works interactively for me as well but that defeats the purpose of a declarative artifact like a Dockerfile. ( The smell of doing an interactive install taints the air ) I guess while this technology is in TP I can live with it. I'll go interactive and then commit the container as an image:

    # Create new container to act as start of base image
    docker run --name choco1 -it windowsservercore cmd
    # Perform choco install (using container tty)
    C:\Windows\system32> @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
    
    C:\Windows\system32> exit
    docker commit choco1 chocobase
  14. dwickern commented on Mar 23, 2016

    @dwickern

    @njappboy my suggestion was merely a way to debug your issue. I would not expect different behavior between interactive mode and a non-interactive build. Did you check if choco actually runs when you install it interactively?

  15. njappboy commented on Mar 23, 2016

    @njappboy

    @dwickern, noted. Interactive install succeeds and it runs correctly from the new base image.

  16. StefanScherer commented on Mar 23, 2016

    @StefanScherer
    ContributorAuthor

    @dwickern @njappboy As a workaround for TP4 you can add a little pause before accessing the network/internet within the container. A sample can be found in this Dockerfile.

  17. njappboy commented on Apr 3, 2016

    @njappboy

    @StefanScherer I'll try this in the am. Have it working with manual install into container and then committing to an image. Now I've hit the same problem with a ONBUILD npm install instruction when building a node application deployment image. I believe you referenced a similar issue with TP3 back in Aug 2015. Don't see a resolution to that issue. The link to the work around by patching binary you mentioned above returns a 404 not found.

  18. StefanScherer commented on Apr 3, 2016

    @StefanScherer
    ContributorAuthor

    @njappboy You're right. Node.js versions change so fast. I've pinned the link https://github.com/StefanScherer/dockerfiles-windows/blob/776120fb5b24c68e73243eb74b440eb4f2c24059/node/5.9/Dockerfile#L13-L15

    Or here is the snippet to patch node.exe:

    RUN wget -Uri https://github.com/StefanScherer/win-patch-iojs/releases/download/1.0.9/patchiojs.exe -OutFile patchiojs.exe -UseBasicParsing ; \
        patchiojs.exe 'C:/Program Files/nodejs/node.exe' ; \
        Remove-Item -Path patchiojs.exe
  19. StefanScherer commented on Apr 18, 2016

    @StefanScherer
    ContributorAuthor

    Is the patch still needed with TP5 to make npm install work in a Windows Container?

    From one of the last comments in nodejs/node#2578 (comment) :

    If the usage of AI_ADDRCONFIG will affect a released version of Windows — post a comment here, this will be reopened.

    Will this be fixed in final Server 2016?

  20. StefanScherer commented on Apr 27, 2016

    @StefanScherer
    ContributorAuthor

    Seems to be fixed with TP5. My test proggy getaddrinfo.exe as well as node.exe / npm install works inside a Windows Container.
    Tested with getaddrinfo.exe both in windowsservercore and nanoserver.

  21. StefanScherer commented on Apr 27, 2016

    @StefanScherer
    ContributorAuthor

    So nobody needs the patchiojs.exe any more 🎉

  22. added this to the Windows TP5 milestone on Apr 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions