Repository navigation
Description
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:
- 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
getaddrinfofunction. - 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 .
- 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
lowenna commentedon Aug 27, 2015
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.
StefanScherer commentedon Aug 28, 2015
Some further investigation a call to
Get-NetAdapterdoes not show the Ethernet Adapter #3, but the both of the host.Running inside a Windows Container:
Running on the Win2016TP Host:
lowenna commentedon Sep 2, 2015
Being tracked internally by 3719364
friism commentedon Jan 13, 2016
@jhowardmsft do you have a status on
3719364? Do you know if it was fixed in TP4?StefanScherer commentedon Jan 13, 2016
AFAIK this is still an issue, I still patch the node.exe and tested it once with TP4 without the patch.
lowenna commentedon Jan 13, 2016
The bug is still showing as open and active internally.
friism commentedon Jan 13, 2016
Thanks @jhowardmsft!
hoho commentedon Feb 8, 2016
I have the same issue. Are there known workarounds?
StefanScherer commentedon Feb 8, 2016
@hoho for Node.js in a Windows Container I still use this workaround patching the binary.
dwickern commentedon Mar 1, 2016
I had the same issue with this dockerfile:
njappboy commentedon Mar 22, 2016
@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 RUNchoco install -ycommands 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 anychoco installattempts are made. There is no chocolatey folder in the C:\ProgramData folder. Any ideas?dwickern commentedon Mar 22, 2016
@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 cmdthen run the first command.njappboy commentedon Mar 23, 2016
@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 cmddwickern commentedon Mar 23, 2016
@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?
njappboy commentedon Mar 23, 2016
@dwickern, noted. Interactive install succeeds and it runs correctly from the new base image.
StefanScherer commentedon Mar 23, 2016
@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.
njappboy commentedon Apr 3, 2016
@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 installinstruction 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.StefanScherer commentedon Apr 3, 2016
@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:
StefanScherer commentedon Apr 18, 2016
Is the patch still needed with TP5 to make
npm installwork in a Windows Container?From one of the last comments in nodejs/node#2578 (comment) :
Will this be fixed in final Server 2016?
StefanScherer commentedon Apr 27, 2016
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.
StefanScherer commentedon Apr 27, 2016
So nobody needs the patchiojs.exe any more 🎉