Docker: Container Networking

Bridge Networking

bridge or NAT on Windows

aka docker0

But each Bridge is isolated (i.e. an island –  they can’t talk to another bridge network) unless we map ports to the host. This is where overlay networking comes in.

Note, out of the box you get a bridge network called bridge. And inspecting it with docker network inspect bridge you can see something like:

Note how  "Containers": {}, – i.e. no containers.

So, if we ran a container (e.g. docker container run --rm -d alpine sleep 1d) we’d see it on the bridge network.

Overlay Networking

This is a single Level 2 network (Level 2 => MAC addresses; Level 3 => IP addresses) which works on different networks.

docker network create

Control plane encrypted out of the box.

Note:

docker network create -d

-d =>  –driver

E.g. docker network create -d overlay overnet

 

MACVLAN

Lets you have an IP / Mac address on the network. But must allow promiscuous mode – which is disabled in cloud.

Example of an overlay network

Assuming we’ve got a swarm set up:

  • create a service

docker service create -d --name pinger --replicas 2 --network overnet alpine sleep 1d

Leave a Reply

Your email address will not be published. Required fields are marked *