docs(docker): explain how to persist DNS configuration

This commit is contained in:
jon r 2024-10-11 15:35:24 +02:00
parent 15a9533330
commit ac4600cec9
1 changed files with 38 additions and 1 deletions

View File

@ -116,7 +116,44 @@ Then run the network services to access the running containers.
sudo resolvectl domain docker0 '~funkwhale.test.'
```
Please refer to the manual of your distribution for other configurations.
This is a temporary setting that will be lost after a reboot.
A superuser of the system can persist this setting by providing a
systemd service that `BindsTo=` the `docker0` device. This requires `sudo`
privilege.
```sh
sudo sh -c "umask 133; tee /etc/systemd/system/funkwhale-dns-docker0.service" <<< "[Unit]
Description=Funkwhale per-link DNS configuration for docker0
BindsTo=sys-subsystem-net-devices-docker0.device
After=sys-subsystem-net-devices-docker0.device
[Service]
Type=oneshot
ExecStart=/usr/bin/resolvectl dns docker0 172.17.0.1
ExecStart=/usr/bin/resolvectl domain docker0 '~funkwhale.test.'
ExecStopPost=/usr/bin/resolvectl revert docker0
RemainAfterExit=yes
[Install]
WantedBy=sys-subsystem-net-devices-docker0.device
"
sudo systemctl daemon-reload
sudo systemctl enable --now funkwhale-dns-docker0.service
```
This gives you a systemd unit, whose life cycle is bound to the `docker0`
network device.
```sh
systemctl status \
funkwhale-dns-docker0.service \
sys-subsystem-net-devices-docker0.device
```
Please refer to the manual of your distribution for other configurations,
e.g. with system installations of netplan, systemd-networkd, NetworkManager, resolvconf or dnsmasq. Ensure the search domain is set to `funkwhale.test.`
and the nameserver address is set to `172.17.0.1`.
:::