Skip to main content
Welcome to this comprehensive guide on deploying a multi-container voting application stack with Docker Compose. In this tutorial, you’ll learn how to set up and run various interconnected services that form a complete voting app ecosystem.
The image shows a webpage from Docker Docs detailing the installation process for Docker Compose, including prerequisites and installation instructions for various operating systems.
Docker Compose is not included by default when Docker is installed. You need to install it separately. For instructions tailored to your operating system (Mac, Windows, or Linux), please refer to the Docker documentation.
Since this demo runs on Linux, follow these steps to install Docker Compose:
  1. Download the Docker Compose binary using curl.
  2. Set executable permissions.
  3. Verify the installation with the version command.
Before we proceed, ensure that any previously running containers are stopped. Confirm no containers are active using:

Creating the Docker Compose File

Next, create a docker-compose.yml file that defines the required services for the voting application architecture. The stack includes:
  • Redis – Key-value store used by various services.
  • DB – PostgreSQL database (image version 9.4).
  • Vote – The voting web application.
  • Worker – Processes voting logic and communicates with both Redis and DB.
  • Result – Displays the voting results.
Start by using the cat command to create the file:
Then, add the following service definitions with the necessary images, port mappings, and service linkages:
In this configuration:
  • The vote service maps container port 80 to host port 5000.
  • The result service maps container port 80 to host port 5001.
  • The links attribute creates communication channels among the containers (e.g., vote connects to Redis, and worker connects to both Redis and DB).
Save the file once the configuration is complete.

Starting the Application

Launch the application stack by running:
The output should confirm that the containers are being created, similar to:
Note that the container names are prefixed with the current directory name (in this case, “root”)—a standard behavior of Docker Compose. As the containers initialize, you will see logs indicating the startup process. Here is an example snippet of the logs:
Once all containers are running, you can access the voting application to cast votes and view the results.
A webpage titled "Cats vs Dogs!" with voting options for "CATS" and "DOGS," showing "DOGS" selected. It includes a container ID and a tip about changing votes.
Thank you for following along in this guide. We hope this tutorial has enhanced your understanding of deploying multi-container applications with Docker Compose. Happy deploying!

Watch Video