Skip to content
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

No DNS Search Domain support in Alpine Linux image due to muslc #602

Closed
Mickael-van-der-Beek opened this issue Dec 24, 2017 · 13 comments
Closed

Comments

@Mickael-van-der-Beek
Copy link

Mickael-van-der-Beek commented Dec 24, 2017

It seems like dns.lookup() calls will not work in Node.js's Alpine Linux image versions when search domains are used.

Calls like dns.resolve() won't work for a different reason which is C-Ares having issues with the feature.

Alpine Linux uses musl libc instead of gnu libc, the former didn't support search domains until version 1.1.13. It seems though that even on more recent versions of musl libc, the bug persists.

cf: https://wiki.musl-libc.org/functional-differences-from-glibc.html#Name_Resolver_.2F_DNS
cf: gliderlabs/docker-alpine#8

To make reproduction of this issue easier, I created a repository with one Debian and one Alpine Dockerfile that you can find here:

https://github.com/Mickael-van-der-Beek/c-dns-test

Edit: Might also be related to mhart/alpine-node#107

@SimenB
Copy link
Member

SimenB commented Dec 24, 2017

Is this actionable for us? Or is it a bug with node and musl?

@LaurentGoderre
Copy link
Member

Perhaps not but this kind of issue should be tracked for a case to the broader node community for official support of Alpine Linux.

@bnoordhuis
Copy link
Member

bnoordhuis commented Dec 25, 2017

See nodejs/node#17850. I'd say this can be closed because it's not an issue with alpine, musl or docker - dns.lookup() dns.resolve() simply does not support search domains at the moment.

@Mickael-van-der-Beek
Copy link
Author

@bnoordhuis If you look at the Node.js DNS test repository I created, lookup does work and resolve doesn't:

https://github.com/Mickael-van-der-Beek/node-dns-test

If you then run the syscall in C directly, you will see that there is in fact a difference between Debian and Alpine Linux for the same source code:

https://github.com/Mickael-van-der-Beek/c-dns-test

@bnoordhuis
Copy link
Member

Sorry, typo in my comment - I meant dns.resolve(), not dns.lookup().

If you then run the syscall in C directly, you will see that there is in fact a difference between Debian and Alpine Linux for the same source code

Can you summarize the differences?

@Mickael-van-der-Beek
Copy link
Author

Mickael-van-der-Beek commented Dec 27, 2017

If you do a getaddrinfo() call with google and use the Belgian TLD be as the search domain, we get 216.58.214.35 for Debian and code -2 (verbose error: Name does not resolve) for Alpine Linux.

If we inspect both containers, the docker compose utility sets up this /etc/resolv.conf file:

# cat /etc/resolv.conf
search be
nameserver 127.0.0.11
options ndots:0

Which looks fine.

The only difference is that in the Debian case we use:

ldd (Debian GLIBC 2.24-11+deb9u1) 2.24

and in the Alpine Linux case:

musl libc (x86_64) Version 1.1.18

From the issue thread below, you can see that the feature was supposedly implemented in muslc@1.1.13 but even in edge versions of Alpine Linux which come with more recent versions of muslc, the problem still exists:

gliderlabs/docker-alpine#8

In that sense it's not a Node.js issue, just an Alpine Linux issue but it's still interesting to document the issue for posterity.

@Mickael-van-der-Beek
Copy link
Author

Mickael-van-der-Beek commented Dec 27, 2017

@bnoordhuis Just to clarify, the issue I described above is valid for the dns.lookup() call and the ticket I opened on the main Node.js repository is about the language not using the C-Ares that supports DNS search domains in the dns.resolve() call.

@bnoordhuis
Copy link
Member

Ah, I get it now. That's a documented difference with glibc: musl ignores search/domain for names with dots >= ndots. Since 0 >= 0, it's always going to do a regular lookup.

With ndots:1, musl and glibc behave the same for a bareword domain name (but not for e.g. domain.tld because that requires ndots:2.)

Is that options ndots:0 a docker default? I don't believe our docker image sets that.

@Mickael-van-der-Beek
Copy link
Author

@bnoordhuis That seems to indeed be the default value in Docker based on libnetwork:

https://github.com/docker/libnetwork/blob/19ac3ea7f52bb46e0eb10669756cdae0c441a5b1/resolver.go#L204

BlueCatBlog pushed a commit to BlueCatBlog/myDSI that referenced this issue May 8, 2018
@CoreyCole
Copy link

I'm trying to make requests from an alpine node container to another container and running into dns issue ENOTFOUND. Is this related to this issue?

https://stackoverflow.com/questions/50263684/docker-compose-networking-with-axios-node-error-enotfound

@CoreyCole
Copy link

CoreyCole commented May 10, 2018

I get the same ENOTFOUND error that I get in node:8.11-alpine when I switch to node:8.11, so my issue is probably unrelated

@chorrell
Copy link
Contributor

Closing as an Alpine/Docker issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants