Quiz Entry - updated: 2026.06.20
How do you connect multiple Docker containers?
Attach containers to a shared Docker network so they can reach each other by container name as a hostname.
# Create a network
$ docker network create web
# Create containers on the network
$ docker create --network web -p 80:80 --name myapp myapp:latest
$ docker create --network web --name mydb mongo:latest
# Start containers
$ docker start myapp
$ docker start mydb
Containers on the same network can communicate using container names as hostnames (e.g., myapp can connect to mydb:27017).