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

Fixes #275 : use host dns with slirp4netns support in rootless mode #374

Merged
merged 1 commit into from Sep 21, 2021

Conversation

hypnoce
Copy link
Contributor

@hypnoce hypnoce commented Sep 20, 2021

This is a first draft written this afternoon. I need to test it more.
In rootless and rootful mode, parse host resolv.conf the 'docker' way : if non-local DNS are found, use them. If no non-local DNS is found, use default google DNS servers. In case DNS is 127.0.0.53, parse an alternative resolv file.
In rootless mode, add the slirp4netns dns as 1st nameserver

…ess mode

Signed-off-by: Francois JACQUES <fjacques@murex.com>

// Package resolvconf provides utility code to query and update DNS configuration in /etc/resolv.conf
// originally from https://github.com/moby/moby/blob/6014c1e29dc34dffa77fb5749cc3281c1b4854ac/libnetwork/resolvconf/resolvconf.go
package resolvconf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, if you have used functions from moby or other, please put the reference to the original function
example

// eventsActions is from https://github.com/containerd/containerd/blob/v1.4.3/cmd/ctr/commands/events/events.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the whole file. Should I put the comment on top of each function ?

if err != nil {
return err
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, but I guess we do not need to detect the slirp4netns DNS.

We can just use /etc/resolv.conf (/run/systemd/resolve/resolv.conf) for both rootful and rootless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, in case of rootless we run in the mount ns of rootlesskit thus having the /etc/resolv.conf containing the slirp dns right ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess we can merge this right now and revisit later.

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to show Docker/Moby copyrights too.

Like this:

/*
Portions from https://github.com/moby/moby/blob/v20.10.1/api/types/types.go
Copyright (C) Docker/Moby authors.
Licensed under the Apache License, Version 2.0
*/

@AkihiroSuda AkihiroSuda added this to the v0.12.0 milestone Sep 21, 2021
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

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

Successfully merging this pull request may close these issues.

None yet

3 participants