chapter eleven

11 Services with Docker and Compose

 

This chapter covers

  • Understanding Services and how they relate to containers
  • Basic service administration with Docker Swarm
  • Building declarative environments with Compose and YAML
  • Iterating on projects with Compose and the deploy command
  • Scaling services and cleaning up
  • Modeling volumes and networks with Compose

Today most of the software we run is designed to interact with other programs not human users. The resulting webs of inter-dependent processes serve some collective purpose like processing payments, running games, facilitating global communications, or delivering content. When you look closely at that web you’ll find individual running processes that might be running in containers. Those processes are allocated memory and given time on CPU. They are bound to a network and listen for requests from other programs on specific ports. Their network interface and port are registered with some naming system so they are discoverable on that network. But as you expand your view and examine more processes you’ll notice that most of them share common characteristics and goals.

11.1   A Service “Hello, World!”

11.1.1   Automated resurrection and replication

11.1.2   Automated Rollout

11.1.3   Service health and rollback

11.2   Declarative Service Environments with Compose V3

11.2.1   A YAML Primer

11.2.2   Collections of Services with Compose V3

11.3   Stateful services and preserving data

11.4   Load balancing, service discovery, and networks with Compose

11.5   Summary