The voting application

As mentioned already, our Docker Compose file is quite a simple example. Let's take a look at a more complex Docker Compose file and see how we can introduce building containers and multiple networks.

In the repository for this book, which is available at, you will find a folder in the chapter06 directory called example-voting-app. This is a fork of the voting application from the official Docker sample repository, which can be found at

As you can see, the application is made up of five containers, two networks, and a single volume. Let's walk through the YAML file as there is a lot going on:

version: "3"services:

Our first container ...

Get Mastering Docker - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.