mynetwork. Container A tries to ping Container B using its container name. What will be the output of the ping command inside Container A?docker network create mynetwork docker run -dit --name containerB --network mynetwork alpine sh docker run -dit --name containerA --network mynetwork alpine sh docker exec containerA ping -c 1 containerB
Docker user-defined bridge networks provide built-in DNS resolution. Containers can reach each other by their container names as hostnames.
Docker Swarm includes an internal DNS server that automatically resolves service names to the IP addresses of the running tasks, enabling easy service discovery.
ping: unknown host containerB. What is the most likely cause?The default bridge network does not provide automatic DNS resolution by container name. Only user-defined bridge networks support this feature.
web service use to connect to the db service?version: '3.8'
services:
web:
image: nginx
depends_on:
- db
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: exampleDocker Compose creates a default network where services can resolve each other by their service names as hostnames.
Docker's default networking does not support cross-host DNS resolution without orchestration. External tools like Consul or etcd provide scalable, automated service discovery.
