Deploying Multi-Service Apps
Deploy a full-stack application with a database and backend service using Docker Compose.
Deploying Multi-Service Apps is a free Docker & DevOps Fundamentals lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Docker & DevOps Fundamentals learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Deploy Multi-Service Apps
Welcome! In this lesson, we'll learn how to bring a full-stack application online using Docker Compose.
You'll see how to define multiple services like a web app and a database, then deploy and manage them together.

Our Example: Web & DB
We'll deploy a simple web application that connects to a database. This is a common setup for many real-world applications.
- Web Service: A Python Flask application that serves a basic webpage.
- Database Service: A PostgreSQL database to store data.
Docker Compose makes orchestrating these two services easy!
Building the Web Image
Our web service needs its own Docker image. Here's a simplified Dockerfile that builds our Python Flask application.
It installs Flask and a PostgreSQL connector, then runs our app.py.
FROM python:3.9-slim-buster
WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir flask psycopg2-binary
EXPOSE 5000
CMD ["python", "app.py"]The `docker-compose.yml`
This docker-compose.yml file defines our two services: web and db. Notice how the web service builds from our Dockerfile and connects to the db service using environment variables.
version: '3.8'
services:
web:
build: .
ports:
- "5000:5000"
environment:
DB_HOST: db
DB_NAME: mydatabase
DB_USER: user
DB_PASSWORD: password
depends_on:
- db
db:
image: postgres:13
environment:
POSTGRES_DB: mydatabase
POSTGRES_USER: user
POSTGRES_PASSWORD: password
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:Starting Up Your Services
To start all services defined in your docker-compose.yml file, you use the docker compose up command.
The -d flag runs the containers in "detached" mode, meaning they run in the background.
# This command starts your multi-service app
# and runs it in the background.
docker compose up -dVerify Running Containers
After running docker compose up -d, you'll want to check if all your services are running as expected.
The docker compose ps command lists the services, their status, and ports.
# Check the status of your services
docker compose psConnect to Your App
With the services running, you can access your web application.
- Open your web browser.
- Navigate to
http://localhost:5000.
You should see a message from our Flask app, confirming its connection to the PostgreSQL database!
Scaling Services
One powerful feature of Docker Compose is scaling services. If your web app needs to handle more traffic, you can easily increase the number of web service instances.
Use the --scale flag with docker compose up.
# Scale the 'web' service to 3 instances
docker compose up --scale web=3 -dStopping & Removing Services
When you're done with your application, you can stop and remove all the services and their networks defined in your docker-compose.yml.
The docker compose down command handles this cleanup for you.
# Stop and remove all services
docker compose downQuick Check
Consider the docker-compose.yml we used. You've just started your application with docker compose up -d.
What is the primary command to stop and remove all the running services and their associated resources?
Recap & Next Steps
Great job! You've learned how to deploy and manage a multi-service application using Docker Compose.
- We defined services in
docker-compose.yml. - We used
docker compose up -dto start services. - We verified status with
docker compose ps. - We scaled services and used
docker compose downfor cleanup.
This is a fundamental skill for local development and testing of complex applications!
Frequently asked questions
Is the “Deploying Multi-Service Apps” lesson free?
Yes — the full text of “Deploying Multi-Service Apps” is free to read here on the web, and the Docker & DevOps Fundamentals course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Docker & DevOps Fundamentals course, upgrade to CoddyKit PRO.
What will I learn in “Deploying Multi-Service Apps”?
Deploy a full-stack application with a database and backend service using Docker Compose. You practise Docker & DevOps Fundamentals with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Docker & DevOps Fundamentals?
No prior experience is required. Docker & DevOps Fundamentals on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Deploying Multi-Service Apps” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Docker & DevOps Fundamentals lesson?
Yes. Every Docker & DevOps Fundamentals lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What is Docker Compose?
- Writing a Compose File
- Deploying Multi-Service Apps
- Environment Variables and .env Files