Learning Docker Networking — Part 2

Before reading this part, make sure you already read the part1.

There two different ways of doing networking in Docker:

  • Networking in a single host
  • Networking in a cluster of two ore more hosts

In part1, we have seen the Single Host Networking mode.

You may be interested in getting Your Free Docker Cheat Sheet

In a single host, containers are able to see each other, to see the external world (if they are not running in isolated networks) and they can receive traffic from an external network.

There is another mode of networking: the multihost.

Multi Host Networking

An application could be run using many containers with a load balancer, these containers could be spread across multiple hosts.

Networking in multi host environments is entirely different from single host environments.

Containers even spread across servers should be able to communicate together, this is where service discovery plays an important role in networking.

Service discovery allows you to request a container name and get its IP address back.

Docker comes with a default network driver called overlay that we are going to see later in this chapter.

If you would like to operate in the multi host mode, you have some options:

  • Using Docker engine in Swarm mode
  • Running a cluster of hosts using a key value store (like Zookeeper, etcd or Consul) that allows the service discovery
Multi Host Networking Using A KV Store

What’s Next

In the part3, we’re going to see the default Docker networks like:

  • None network
  • Docker Host Network
  • Bridge Network
  • docker_gwbridge Network

Connect Deeper

This blog post is inspired from my course Painless Docker.

You may be interested in getting Your Free Docker Cheat Sheet

Stay in touch!