nerdctl icon indicating copy to clipboard operation
nerdctl copied to clipboard

Proposal: Change the DNS impl for the nerdctl network

Open Zheaoli opened this issue 1 year ago • 4 comments

What is the problem you're trying to solve

For now, the nerdctl uses the /etc/hosts file to record the DNS for the different containers.

But in some circumstances, we need to maintain the different hosts file for different containers (add a record when a container create successfully, delete a record when a container delete successfully)

If the file is not right, there should be some DNS issues for the user, such as #1149

So maybe we need to use a better way to record the DNS.

Describe the solution you'd like

Maybe we can use dnsname as a reference.

The dnsname makes a CNI plugin to record the DNS item. It allocates a dnsmasq process for each network. I think it's a good example for us.

cc @AkihiroSuda @junnplus @fahedouch

Additional context

No response

Zheaoli avatar Sep 19 '22 15:09 Zheaoli

@AkihiroSuda would you mind helping me to add a label kind/proposal for this project?

Zheaoli avatar Sep 25 '22 17:09 Zheaoli

SGTM, I think it is a good idea to delegate dns recording to the dnsmasq rather than nerdctl

fahedouch avatar Sep 25 '22 21:09 fahedouch

SGTM as an opt-in.

The default should remain files, as dnsname is not a part of https://github.com/containernetworking/plugins

AkihiroSuda avatar Sep 25 '22 22:09 AkihiroSuda

The default should remain files, as dnsname is not a part of https://github.com/containernetworking/plugins

Yes, the people can choose DNS engine theirself

Zheaoli avatar Sep 26 '22 12:09 Zheaoli

Please let me know if I'm hitting this limitation or a different one:

When running nginx using docker, the correct way to use the resolver command is to pass it the ip of the Docker DNS resolver, 127.0.0.11

When running nginx using docker, nerdctl-provided DNS resolver (whatever it writes in /etc/resolv.conf, 172.17.32.21 in my case) can only resolve external names, and any names on the nerdctl network are hardcoded in /etc/hosts only, so nginx cannot resolve them.

orthoxerox avatar Feb 19 '23 16:02 orthoxerox