-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Bug: systemd-resolved issues #580
Comments
Hey @ratcashdev , DPS won´t be able to configure itself as the default DNS when running inside a docker container when the host is using system-resolved. Yep, you will do need to restart systemd-resolved using service or systemctl command, see more details about the limitation. If you are using DPS as your primary DNS solver I would recommend follow theses steps to configure it as a service and don't have to reconfigure systemd-resolved at every restart. In alternative you can bypass systemd-resolved and use resolv.conf without the need to restart any service by following these instructions: services:
dns-proxy:
image: defreitas/dns-proxy-server
hostname: dns
volumes:
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
- type: bind
source: /etc
target: /host/etc
environment:
- MG_RESOLVCONF=/host/etc/resolv.conf
ports:
- "5380:5380" |
HI @mageddo thanks for the quick replay and solution.
can you plz elaborate what is the fundamental issue here? |
Basically systemd-resolved need to be restarted and it's a host program, a host program can't be executed from the docker container as expected by the isolation principle, DPS is running inside a docker container so it can´t restart the host system-resolved at the host. |
@mageddo I have tried your suggested setup above. Unfortunately, it seems it still does not work.
|
I will do a check, looks like DPS hasn't permission to edit |
yeah, pretty much:
|
Got it.
# ls -lha /host/etc/resolv*
lrwxrwxrwx 1 root root 39 Sep 15 2022 /host/etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf So you need to run like below: services:
dns-proxy:
image: defreitas/dns-proxy-server
hostname: dns
volumes:
- /run/systemd/resolve/:/host/run/
environment:
MG_RESOLVCONF: /host/run/stub-resolv.conf
ports:
- "5380:5380"
Improving the logs to make the failing condition explicit at #585 . |
This issue is stale because it has been waiting-feedback for 15 days with no activity. |
This issue was closed because it has been inactive for 7 days since being marked as stale, you can reopen it at any time. |
Tested this today. Unfortunately, it still does not work. Logs look good, but a simple ping to a hostname registered in the compose file fails. logs:
/etc/resolv.conf (linked to /run/systemd/resolve/stub-resolv.conf) now looks like this:
|
@ratcashdev can you confirm that DPS is being used as the default DNS? can you see query entries at DPS logs? If your /etc/resolv.conf keeps with You can ping |
@mageddo unfortunately none of the pings work and I don't see any name queries in the DPS logs. |
Looks like systemd-resolved is acting and ignoring resolv.conf. If you really want to run DPS inside docker container you can set an static IP for DPS container and configure it on systemd-resolved as following (you will need to use DPS 3.30.5-snapshot): services:
dns-proxy:
image: defreitas/dns-proxy-server:3.30.5-snapshot
hostname: dns
volumes:
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
networks:
my_network:
ipv4_address: 171.18.0.10
environment:
- MG_LOG_LEVEL=DEBUG
networks:
my_network:
driver: bridge
ipam:
config:
- subnet: 171.18.0.0/16
Locate the DNS= line in the [Resolve] section and add the container's static IP: [Resolve]
DNS=171.18.0.10
FallbackDNS= Restart the systemd-resolved service to apply the changes: DPS will be used when available sudo systemctl restart systemd-resolved |
Thanks for the suggestion. My primary use case was to start dns-proxy from inside docker-compose to allow seamless communication between the host and other containers using host names during integration testing. The requirement to restart resolved makes this a non-practical approach (to the extent of being practically unusable) for my use case. |
What is Happening
starting dns-proxy from within a compose file, like:
ping dns
executed from the host saysName or service not known
The logs, in addition contain the entry:
Not possible to restart resolved service: service systemd-resolved restart
Actually, the command
service
is not present on my machine. Onlysystemctl restart systemd-resolved
works.However, even if I restart
resolved
manually, DNS lookup does not work through dns-proxy.What is Expected
systemd-resolved is restarted and DNS lookup works.
Specs
docker version
27.1.2docker run --rm defreitas/dns-proxy-server --version
3.25.10-snapshotThe text was updated successfully, but these errors were encountered: