In this section, we will focus on host management, that is, the ways we can manage our hosts, what we should use to manage our hosts, how we can monitor our hosts, and container failover, which is very important when something happens to the host that is running critical containers.
With host monitoring you can do so via the command line using Docker Machine as also there are some GUI applications out there that can be useful as well. For Machine, you can use the ls
subcommand:
$ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM amazonhost amazonec2 Error swarm-master * virtualbox Running tcp://192.168.99.102:2376 swarm-master(master) swarm-node1 virtualbox Running tcp://192.168.99.103:2376 swarm-master
You can use some GUI applications out there as well, such as:
Another tool that you can use for node management is that of Docker Swarm. We saw previously how helpful Swarm can be. Remember that you can use Docker Swarm to manage your hosts as well as to create and list them. The most useful command to remember for Swarm is the list
subcommand. With the list
subcommand, you can get a view of all the nodes and their statuses:
Remember that you will need either the discovery service IP or the token number that is used for Swarm:
$ docker run swarm list token://<swarm_token>
With Docker Swarm, you can set up your manager node to be highly available. That is, if the managing host dies, you can have it failover to another host. If you don't have it set up, there will be a service interruption, as you won't be able to communicate to your hosts anymore and will need to reset them up to point to the new Docker Swarm manager. You can set up as many replicas as you want.
To set this up, you will need to use the --replication
and --advertise
flags. This tells Swarm that there will be other managers for failover. It will also tell Swarm what address to advertise on, so the other managers know on what IP address to connect for other Swarm managers.