We won't go through the whole API. The official documentation (https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/) is well written and provides enough details. Instead, we'll go through some basic examples focused around Docker Swarm. We'll see how we can use the API by repeating some of the client commands we practiced earlier. The goal of this chapter is to get just enough knowledge to be able to use the API in your applications as well as a glue between different services we'll explore in the next chapters. Later on, we'll try to leverage this knowledge to create a monitoring system that stores the information about the cluster in a database and performs some actions.
Let's discuss a very simple example of a possible use case for the API.
If a node fails, Swarm will make sure that the containers that were...