Difficulty: Intermediate
Estimated Time: 10 minutes

This scenario explains how to allow containers on two different hosts to communicate. By using features added in Docker 1.9, a multihost network allows containers to behave as if they are on the same machine. Ideal for scaling and redundancy without having to open public ports.

The Environment

The environment has been configured as a two node cluster. Both nodes are independent and communicate via IPv4.

Changing Docker Daemon Parameters

Multihost networking requires additional parameters when launching the Docker Daemon.

To simulate this the course will launch a Docker Daemon as a container. This will give you a Docker 1.10 daemon with the correct parameters. This is only for training, in production you should change the way you launch the Docker Daemon.

This scenario explained how to use the features added in Docker 1.9 to communicate with containers across a network. By registering containers with a Docker network they can communicate without requiring public ports.

The steps required are:

1) Launch Consul on accessible machine

2) Update Docker Daemons to register themselves on launch with Consul

3) Register containers to a network

4) Containers can communicate transparently

Docker Multihost Networking Hello World

Step 1 of 6

Step 1 - Configure Key/Value Store

To begin you need to have a running instance of Consul that is accessible to both Docker Daemons. We'll launch this as a container on Host01.

docker run -d --name consul \
  -p 8300:8300 -p 8400:8400 -p 8500:8500 -p 53:8600/udp \
  gliderlabs/consul-server:latest -bootstrap


In production you'll need to run Consul on either a third Docker daemon or host machine. When the daemon launches the Consul server needs to be running and accessible.

Terminal Host 2