Container name doesnt resolve when using another container as Network Mode

Running on Ubuntu 22.04.2
Docker version 25.0.3
Im having issues resolving container name through DNS when using another container as the network mode

Sorry if this is a stupid question, but Ive been hitting a brick wall when researching this topic. I have a media server Ive written up in compose that runs a vpn, bunch of *arrs, qbittorrent, and some media organization. In this particular example I have the vpn, sonarr, qbittorrent, and Jellyfin.

Docker-compose here

vpn-network is external and created as a standard bridge network, I know there are issues resolving container names with the default network.

So the issue Im having is when connecting between apps. To connect Sonarr to Qbittorrent, I use localhost:8085 as they are both using Proton as their network mode and all the ports are exposed, works great.

My issue is when I want to connect from Sonarr to Jellyfin. Sonarr is not able to send a test to jellyfin saying it cant resolve the name

Unable to send test message: Name does not resolve (jellyfin:8096)

However if I get the actual ip when checking the vpn-network and plug that in, its able to find Jellyfin.

Some other information, when running ‘docker exec -it sonarr cat /etc/resolv.conf’ or for vpn I see

nameserver 127.0.0.1
options edns0 trust-ad ndots:0

and when running ‘docker exec -it jellyfin cat /etc/resolv.conf’ I get

nameserver 127.0.0.11
options edns0 trust-ad ndots:0

So what’s the deal with the DNS, I assume this is because I am using network_mode to use the vpn container. Not only that but since it is a vpn with a connection outwards. I know I dont have to use a vpn with sonarr but I would like to keep everything tucked behind a vpn for privacy reasons.

I’ve yet to completely rule out that this is just a sonarr bug, but considering its explicitly saying the name doesn’t resolve I don’t think it is.
I can confirm that DNS works for other apps, I have nginxproxymanager running that routes traffic to Jellyfin and other services I have running and that uses container names completely fine, no problems there.

Obviously I can look up the ip and use that, but thats going to change when I restart things, make changes, etc and I dont want to have to manually update all these things. Using container names is so much more reliable.

Of course after dealing with this for a week or so and finally deciding to make some posts, I figured it out last night. This Gluetun image I am using (qmcgaw/gluetun) for my vpn actually has a DNS_ADDRESS env variable that by default is set to 127.0.0.1 . Literally just set that to DNS_ADDRESS=127.0.0.11 (the address for Docker’s DNS) and everything works as expected again. As expected, I was dumb.