Running Your Dockerized Voting App (Without Docker Compose)

Prerequisites
Before we begin, ensure you have the following installed on your machine:
Docker Desktop: This includes the Docker Engine and Docker CLI. You can download it from Docker's official website.
Git: To clone the project repository.
Step 1: Clone the GitHub Repository
First, you need to get the application code and Dockerfiles onto your local machine. Replace <
https://github.com/dockersamples/example-voting-app.git>
with the actual URL of your GitHub repository.
git clone https://github.com/dockersamples/example-voting-app.git
cd example-voting-app # Navigate into the cloned project directory
Now, your current terminal directory should be the root of your cloned repository, where you'll find the vote/
, worker/
, result/
directories, and potentially a docker-compose.yml
(though we won't be using that file for these instructions).
Step 2: Build Docker Images for Each Service
Navigate into each service's directory from your repository root and build its Docker image.
Build
vote
app image:cd vote docker build -t voting-app . cd ..
Build
worker
app image:cd worker docker build -t worker-app . cd ..
Build
result
app image:cd result docker build -t result-app . cd ..
Step 3: Run Docker Containers (Order Matters!)
Now, we'll run each container. It's crucial to start the database and Redis first, as the worker
and result
apps depend on them.
Run redis container:
This uses the official redis image
docker run -d --name=redis redis
Run db (PostgreSQL) container:
This uses the official postgres image, sets up the database name and credentials.
docker run -d --name=db -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres
(Note: Docker will automatically create the
db-data
volume if it doesn't exist.)Run worker container:
This uses the worker-app image we built and passes the necessary environment variables for connecting to Redis and PostgreSQL.
docker run -d --link redis:redis --link db:db worker-app
Run vote container:
This uses the vote-app image and maps host port 5000 to container port 80 for web access.
docker run -d --link redis:redis -p 5000:80 voting-app
Run result container:
This uses the result-app image, maps host port 5001 to container port 80, and passes environment variables for PostgreSQL connection.
docker run -d -p 5001:80 --link db:db result-app
Step 4: Verify and Access Your Application
After running all the commands, you can check if all containers are running:
docker ps
You should see redis
, db
, worker
, vote
, and result
listed with Up
status.
Now, open your web browser to access the applications:
Voting App:
http://localhost:5000
Result App:
http://localhost:5001
Step 5: Clean Up (Stop and Remove Containers/Network)
When you're done, it's good practice to stop and remove the containers and the custom network to free up resources.
Stop all containers:
docker stop vote result worker db redis
Remove all containers:
docker rm vote result worker db redis
This detailed sequence of docker
commands will get your multi-service voting application up and running without relying on Docker Compose.
Subscribe to my newsletter
Read articles from Hritik Raj directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Hritik Raj
Hritik Raj
👋 Hey there! I'm a university student currently diving into the world of DevOps. I'm passionate about building efficient, scalable systems and love exploring how things work behind the scenes. My areas of interest include: ☁️ Cloud Computing 🔧 Networking & Infrastructure 🛢️ Databases ⚙️ Automation & CI/CD Currently learning tools like Docker, Kubernetes, and exploring various cloud platforms. Here to learn, build, and share my journey. Let’s connect and grow together! 🚀