This repository was archived by the owner on Feb 24, 2020. It is now read-only.
-
Couldn't load subscription status.
- Fork 881
populate /etc/resolv.conf #2032
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56b7d6a to
6d67b61
Compare
rkt now provides /etc/resolv.conf in each app's chroot if it does not
exist. If the ACI provides such a file, rkt does not touch it.
The "nameserver" entries come from two sources:
1. as a comma-separated list from the command line (--dns=xx.xx.xx.xx)
2. from the selected network (--net=...)
If the 'host' network is requested, it copies /etc/resolv.conf from the
host. If another network is requested, it gets the name servers from the CNI
plugins.
Implementation detail: systemd-nspawn can overwrite /etc/resolv.conf. It
is supposed to overwrite it only when the container uses the host
network namespace. However, the container network namespace is created
by rkt via CNI and not by systemd-nspawn, so systemd-nspawn is not aware
of the network configuration. As a consequence, we cannot use stage1's
/etc/resolv.conf. Instead, rkt write /etc/rkt-resolv.conf in stage1 and
prepare-app bind-mounts it in stage2's /etc/resolv.conf.
It works in this way:
> $ cat /etc/rkt/net.d/alban.conf
> {
> "name": "alban",
> "type": "ptp",
> "ipMasq": true,
> "ipam": {
> "type": "host-local",
> "subnet": "172.16.42.0/24",
> "routes": [
> { "dst": "0.0.0.0/0" }
> ]
> },
> "dns": [
> "8.8.4.4",
> "12.12.12.12"
> ]
> }
>
> $ sudo rkt run --net=alban --dns=1.1.1.1,2.2.2.2 \
> sha512-a2fb8f390702 --interactive
> / # cat /etc/resolv.conf
> # Generated by rkt
>
> # Name servers passed on the command line
> nameserver 1.1.1.1
> nameserver 2.2.2.2
>
> # Name servers from CNI
> nameserver 8.8.4.4
> nameserver 12.12.12.12
> / #
|
Depends on containernetworking/cni#99 |
|
Add the dns search domains as well? |
|
@yifan-gu good point, we might also want domain in addition to search. See http://linux.die.net/man/5/resolv.conf. |
|
Postponing this PR: I'll prepare a separate PR for |
4 tasks
|
Yes, it sounds reasonable. |
|
Fixed by #2040 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
rkt now provides /etc/resolv.conf in each app's chroot if it does not
exist. If the ACI provides such a file, rkt does not touch it.
The "nameserver" entries come from two sources:
If the 'host' network is requested, it copies /etc/resolv.conf from the
host. If another network is requested, it gets the name servers from the CNI
plugins.
Implementation detail: systemd-nspawn can overwrite /etc/resolv.conf. It
is supposed to overwrite it only when the container uses the host
network namespace. However, the container network namespace is created
by rkt via CNI and not by systemd-nspawn, so systemd-nspawn is not aware
of the network configuration. As a consequence, we cannot use stage1's
/etc/resolv.conf. Instead, rkt write /etc/rkt-resolv.conf in stage1 and
prepare-app bind-mounts it in stage2's /etc/resolv.conf.
It works in this way:
TODO:
--dns--net=hostFixes #660