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
npm install and other http requests fail with getaddrinfo ENOENT in a Windows Docker container #2578
Comments
Some more details to build the |
Try this: var dns = require('dns');
var dnsopts = {
family: undefined,
hints: dns.ADDRCONFIG | dns.V4MAPPED
};
dns.lookup('registry.npmjs.org', dnsopts, function(err, res) {
console.log(err);
console.log(res);
}); I assume that it would fail. Could you confirm that? |
Thanks @ChALkeR! Yes, this indeed fails:
|
Thanks for confirming.
|
Thanks for the pointer. Changing the
|
So, if I got it right: Could you please check the following:
|
OK, all combinations. My test code C:\app>type dns3.js
var dns = require('dns');
var addr = 'registry.npmjs.org';
dns.lookup(addr, {hints: dns.ADDRCONFIG | dns.V4MAPPED}, function (err, res) {
console.log('dns.lookup(addr, {hints: dns.ADDRCONFIG | dns.V4MAPPED}');
console.log(err);
console.log(res);
dns.lookup(addr, {hints: dns.ADDRCONFIG}, function (err, res) {
console.log('dns.lookup(addr, {hints: dns.ADDRCONFIG}');
console.log(err);
console.log(res);
dns.lookup(addr, {hints: dns.V4MAPPED}, function (err, res) {
console.log('dns.lookup(addr, {hints: dns.V4MAPPED}');
console.log(err);
console.log(res);
dns.lookup(addr, {hints: 0}, function (err, res) {
console.log('dns.lookup(addr, {hints: 0}');
console.log(err);
console.log(res);
});
});
});
}); running this in the Windows container show this:
Seems that the |
Thanks. Looks like Still, according to your The final check here would be to test If you want a workaround, supplying your own lookup function via |
I originally tried to run The
So I think I should ask someone of the Microsoft team that is currently porting Docker on Windows. |
@StefanScherer I updated my previous comment, please re-read it =).
If that fails, this is most likely a Windows/Docker related problem, If it succeeds (which I doubt), then further investigation is needed on the io.js/node side. |
@ChALkeR as you expected the problem can be reproduced with a simple C application. Running this static binary inside the Windows Container works with hints.ai_flags = 0, but fails with hints.ai_flags = AI_ADDRCONFIG:
So I'll open an issue in the Docker repo to ask for help there. Thanks for your help so far. |
@StefanScherer, #2578 (comment):
I doubt that any hacks that are related to Windows 2016 bugs will land to node/io.js until that Windows version is released and is shown to be affected. |
Agree with @ChALkeR, |
Closing the issue for now, this looks like a bug in Windows 2016 Technical Preview 3. |
@silverwind I'll try that, thanks! |
Hi, from TP4 I still have the same issue. I am able to get my node api into a microsoft/node image container but when I run npm install I get the following error:
|
@seanlarge I can confirm that. At the moment I use this workaround in my node 5.10.1 Windows Dockerfile. 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 I watch the progress in moby/moby#15889 as well, there is an internal issue open at Microsoft to address this. Let's see what TP5 will do for us. |
@StefanScherer thank you for the quick reply...does FROM micorsoft/node not work? here is my dockerfile (I have also had a huge problem with 'invalid directories', do I need to change my WORKDIR to have quotes?):
|
@seanlarge The |
@StefanScherer Thank you so much! I will keep an eye on the open issues. |
@StefanScherer I end up with the following error:
|
@StefanScherer my dockerfile:
|
@seanlarge That's another problem of TP4. The network stack is not always up when the RUN command is already running. RUN powershell -Command \
Sleep 2 ; \
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 This is a workaround for TP4, in TP5 the sleep is no longer needed: 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 PS: Perhaps I forgot the |
@StefanScherer still the same issue =( not sure what to do. result:
dockerfile:
|
same thing with docker file from https://github.com/StefanScherer/dockerfiles-windows/blob/776120fb5b24c68e73243eb74b440eb4f2c24059/node/5.9/Dockerfile#L13-L15 I tired FROM windowsservercore instead of microsoft/node, same result. @StefanScherer the problem is that there is no network connection?
|
Same issue here. Woah, moving too fast there, not sure why running the patch failed the first time, this time got the message it was updating hints, after fixing the npm registry it worked. Thank you! |
It seems that is fixed in TP5. Got |
If using Docker, this known issue is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/ Simple fix is to create the file and insert:
where |
binarymist - Where's the /etc dir on Windows? |
|
I'm just trying to point out that a linux answer is not relevant. |
I try to run io.js 3.2.0 inside a Windows Docker container within the Windows 2016 Technical Preview 3.
I encounter problems running
npm install
inside such a container (for a Windows version of the iojs:onbuild Dockerfile) and now I've reduced the problem to a simpler test code.An
http.get()
(orhttps.get()
) request fails inside the container with the error Error: getaddrinfo ENOENTThe
httprequest.js
test code looks like this:But using the
dns
module to try the lookup manually works within the same Docker container:And the
dnstest.js
test code used is this:Any ideas why such lookup inside
http.get()
fails, butdns.lookup()
works fine?This makes it hard to use Node.js/io.js inside a container at the moment.
The
ipconfig /all
inside the container shows this:PS: I also tried a little GO binary inside the container which does pretty the same and that works fine within the Windows Docker container:
The text was updated successfully, but these errors were encountered: