Application Overview
The sample voting application provides two main functions:- A user interface for casting a vote (choosing between cats or dogs).
- A results interface that displays vote counts.
- Voting Application (Python): Presents voting options and sends votes.
- Redis In-Memory Database: Temporarily stores votes.
- Worker Service (.NET): Processes votes and updates the database.
- Results Application (Node.js): Retrieves the vote count from PostgreSQL and displays the results.

- The voting application sends the vote to Redis.
- The worker service processes the vote and updates the PostgreSQL database by incrementing the count for cats.
- The results application fetches the updated count from PostgreSQL and displays it to the user.

Deploying the Application Stack Using Docker
Assuming that Docker images are already built and available in a repository, the deployment process involves starting the data layer followed by application services.Step 1: Starting the Data Layer
First, launch the Redis container in the background to serve as an in-memory data store. The container is given a name for easy reference:Step 2: Deploying the Application Services
Start by launching the front-end voting application. This container runs a web server on port 80, which is published to port 5000 on the host machine:For smooth inter-container communication, explicit linking is necessary. Docker’s linking mechanism helps containers discover and communicate with each other.
Step 3: Linking Containers for Intercommunication
Docker’s linking mechanism updates each container’s/etc/hosts file, enabling hostname resolution between containers. Modify the Docker run commands to include the link options as follows:
- The voting application is linked to the Redis container using
--link redis:redis, allowing it to resolve the hostname “redis”. - The results application is linked to the PostgreSQL container via
--link db:db. - The worker service is similarly linked to the PostgreSQL container.
Sample Code for Service Connectivity
Below are examples of how each service connects to its corresponding dependencies: Python Voting Application (Connecting to Redis):/etc/hosts file, ensuring that services can resolve hostnames (like “redis” or “db”) to the corresponding container IP addresses.
While linking demonstrates the basic concepts of service intercommunication, the
--link option is deprecated. It is recommended to use modern Docker networking solutions such as Docker Swarm or user-defined networks for more robust and scalable container management.