LOGBOOK

HELP

Quiz Entry - updated: 2026.07.31

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.

Two containers on a shared web network: the host publishes port 80 to myapp, which reaches mydb by name at mydb:27017

* On a shared Docker network, containers reach each other by container name as hostname; the host maps port 80 to the app container. *

# 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).

Go deeper:

From Quiz: WEBT / Advanced Topics | Updated: Jul 31, 2026