Connect containers

Docker provides three kinds of networks to manage communications within containers and between the hosts, namely bridge, host, and none.

$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
1224183f2080        bridge              bridge              local
801dec6d5e30        host                host                local
f938cd2d644d        none                null                local

By default, every container is connected to the bridge network upon creation. In this mode, every container is allocated a virtual interface as well as a private IP address, and the traffic going through the interface is bridged to the host's docker0 interface. Also, other containers within the same bridge network can connect to each other via their IP address. Let's run one container that is feeding a short message over port 5000, and observe its ...

Get DevOps with Kubernetes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.