jonathanio / update-systemd-resolved

Helper script for OpenVPN to directly update the DNS settings of a link through systemd-resolved via DBus.
Other
765 stars 94 forks source link

running the script in docker container #79

Closed daniel-habib closed 1 year ago

daniel-habib commented 4 years ago

when i tried running this in a container i was blocked by 2 things: 1/ use of logger (that points to /dev/log that does not exist in a container) 2/ use of busctl (which results in Failed to connect to bus: No such file or directory).

i addressed the first by making logger into echo. the second is more complex :)

is there a way to run it in a container? if not - what is the equivalent of "busctl call" when running in a container?

how to reproduce: start a debian 9 container. sudo apt update sudo apt install nano less wget dbus openvpn openvpn-systemd-resolved -y sudo sed -i -e 's/logger -s --id="$$" -t/echo/g' /etc/openvpn/update-systemd-resolved

create config.ovpn and vpn.login

make sure the config has: script-security 2 up /etc/openvpn/update-systemd-resolved down /etc/openvpn/update-systemd-resolved down-pre

and then sudo openvpn --config config.ovpn --auth-user-pass vpn.login > openvpn.log 2>&1 &

the result:

update-systemd-resolved -p user.info -- SetLinkDNS(...) Failed to connect to bus: No such file or directory update-systemd-resolved -p user.emerg -- 'busctl' exited with status 1

tomeon commented 1 year ago

"How to connect container to DBus from host" may help here. Not sure if these instructions are complete or up-to-date.

For logger, at minimum you'll have to do something like --volume "$(readlink -f /dev/log):/dev/log" when starting the container.