Open ykuksenko opened 2 years ago
@flouthoc PTAL
@ykuksenko I think container1
is only connected to network1
please connect it to network2
as well in order to get it resolved from nameserver in network2
. So podman run --detach --rm -ti --name container1 --network network1,network2 alpine sleep 9000
should be the right thing here.
OTOH you could say that bug is that short name should not get resolved by nameserver if container is not connected to the network of nameserver.
container1
is intentionally connected to only network1
for isolation. For some additional context of where I ran into this issue, I use the following scenario so that the database
is more isolated from the load balancer
:
Load Balancer ------------> Application -------------> Database
(network1) (network2)
In this scenarios the application
container sometimes fails to resolve the database
when addressed with FQDN. I prefer using FQDNs for names because it makes it really obvious what the term refers to and that the name is meant to be internally resolved, and not by my main DNS server.
I suppose the biggest thing I would like to see is consistent behavior:
I do not see any reason for shortnames to resolve and FQDNs to fail or vise versa. If there is such a reason could you share it?
I prefer having both FQDNs and shortnames to be resolvable because:
/etc/resolv.conf
file randomly orders podman network name servers which causes unpredictabilityI am under the impression that netavark and aardvark-dns should combine DNS results from any network a container is connected to according to @mheon (https://github.com/containers/podman/issues/14262#issuecomment-1127977648)
@ykuksenko Does the requested feature works on docker cause this seems a bug a too me I think we should fix this otherway around and make short names also not resolvable if they are not part of the network.
should this be moved to nv?
Sorry for the delay. I do not usually use docker these days.
Docker works a bit differently in this area but it does work intuitively, at least for me.
docker network connect $network_name $container_name
to add the second network. I was not able to find another way with a quick look./etc/resolv.conf
: even when multiple networks are attached. This is the same across all containers
/ # cat /etc/resolv.conf
search mydomain.com vagrant.mydomain.com
nameserver 127.0.0.11
options edns0 trust-ad ndots:0
container1
from this example resolves at container1
and container1.network1
.container1
is only connected to one network I created both container2
and container3
that are both connected to both network1
and network2
and tested resolving container1
and container2
from container3
. As there is only one dns server this is simpler and avoids having the OS figure out which nameserver is responsible for what as well as any timeouts associated with that.From container3
: the following names resolve:
container1 -> 192.168.55.2
container1.network1 -> 192.168.55.2
container1.network2 -> bad address (as it should be as container1
is not connected to network2
container2 -> 192.168.55.3
container2.network1 -> 192.168.55.3
contaner2.network2 -> 192.168.56.2
From container1
things also resolve as expected. Namely only other containers in network1 with both shortnames and fqdns resolve successfully.
Here is the list of commands I ran for setup.
docker network create --subnet 192.168.55.0/24 network1
docker network create --subnet 192.168.56.0/24 network2
docker run --detach --rm -ti --name container1 --network network1 alpine sleep 9000
docker run --rm -ti --name container2 -d --network network1 alpine sleep 9000
docker network connect network2 container2
docker run --rm -ti --name container3 -d --network network1 alpine sleep 9000
docker network connect network2 container3
From there I used the following commands to test:
docker exec -ti container1 apk add bind-tools
docker exec -ti container2 apk add bind-tools
docker exec -ti container3 apk add bind-tools
docker exec -ti container1 cat /etc/resolv.conf #can see above
docker exec -ti container2 cat /etc/resolv.conf #can see above
docker exec -ti container3 cat /etc/resolv.conf #can see above
docker exec -ti container1 dig +short container1 #-> 192.168.55.2
docker exec -ti container1 dig +short container1.network1 #-> 192.168.55.2
docker exec -ti container1 dig +short container1.network2 #-> blank (entry should not exist)
docker exec -ti container1 dig +short container3.network2 #-> blank (container1 is not in network2 so access is denied)
docker exec -ti container3 dig +short container1 #-> 192.168.55.2
docker exec -ti container3 dig +short container1.network1 #-> 192.168.55.2
docker exec -ti container3 dig +short container1.network2 #-> blank (entry should not exist)
docker exec -ti container3 dig +short container2 #-> 192.168.55.3
docker exec -ti container3 dig +short container2.network1 #-> 192.168.55.3
docker exec -ti container3 dig +short container2.network2 #-> 192.168.56.2
docker exec -ti container3 dig +short container3 #-> 192.168.55.4
Hopefully this covers everything.
edit: my docker version: Docker version 20.10.16, build aa7e414
on fedora 36
edit2: change second sentence to be less presumptuous.
A friendly reminder that this issue had no activity for 30 days.
Bump. Happening to me and it's very annoying! @flouthoc I can confirm this works as expected in docker, been using this networking stuff for years.
In fact this issue was first reported early 2021 here: containers/podman#9492
@ykuksenko: The label(s) kind/bug
cannot be applied, because the repository doesn't have them.
@flouthoc @Luap99 @felixsanz is @ykuksenko Is this still an issue?
I move this to aardvark-dns, looks like this is still a problem
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
When a container is connected to multiple networks only one network can resolve containers by fqdn.
Steps to reproduce the issue:
Describe the results you received: When resolving the fqdn of container1 only one name server responds correctly.
When resolving the short name of the container one both name server respond correctly
Describe the results you expected: Both name servers should respond to both the shortname and fqdn queries.
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.): Libvirt VM