How does named container know each other's the ip address in docker user created bridged network? -
docker network create --driver bridge network1 docker run -itd --name docker1 --network network1 busybox docker run -itd --name docker2 --network network1 busybox docker exec -it docker1 /bin/bash
now in docker1, can ping docker2
/ # ping docker2 ping docker2 (172.19.0.3): 56 data bytes 64 bytes 172.19.0.3: seq=0 ttl=64 time=0.056 ms
i thought entry added in /etc/hosts, not
/ # cat /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix 172.19.0.2 841c0dc99115
how docker1 know docker2's ip address?
docker resolves names through internal dns server used docker daemon can check dns adress cat /etc/resolv.conf
understand more can read here
Comments
Post a Comment