Skip to main content
In this lesson, we’ll deploy the Example Voting App using Docker Stacks on a Swarm cluster. We start by upgrading our Compose file to version 3, deploy it as a stack, verify running services, and then scale the voting service.

1. Prepare the Docker Compose File (Version 3)

Below is the upgraded Compose file in version 3 format. Save this as docker-stack.yml on your Swarm manager:
The dockersamples images are available on Docker Hub.
The image shows a Docker Hub profile page for "dockersamples," displaying a list of public repositories with details such as stars and pull counts.
Make sure Docker Swarm is initialized on your manager node:

2. Deploy the Stack

  1. SSH into your Swarm manager and create a project directory:
  2. Place the docker-stack.yml file in this directory.
  3. Deploy the stack:
    You should see output similar to:
    Compose
Verify all services are up:

3. Inspect Running Tasks

On any manager or worker node, list the active containers to ensure tasks are distributed:
Example output:

4. Access the Voting Application

Open a browser and navigate to:
  • Voting interface: http://<manager-ip>:5000
  • Results dashboard: http://<manager-ip>:5001
The image shows a web page titled "Cats vs Dogs!" with options to vote for either "CATS" or "DOGS," and the "CATS" option is selected.

5. Scale the Voting Service

To handle higher traffic, update docker-stack.yml by adding the deploy.replicas setting under the vote service:
Redeploy the updated stack:
Confirm that the voting service now has two replicas:
Inspect each task:
This demonstrates how to deploy, verify, and scale services using Docker Stacks in a Swarm cluster.

Watch Video