The Multi-Container Problem

LEVEL 0

The Problem

Let’s say you’re building a blog application.

You need:

  • A PostgreSQL database to store posts and users
  • A Python/Flask application server that reads from the database
  • An nginx reverse proxy to serve static files and forward requests to Flask
  • A Redis cache to speed up common queries

On your first attempt, you start these containers manually:

# Create a network
docker network create blog-network

# Start PostgreSQL
docker run -d \
  --name blog-db \
  --network blog-network \
  -e POSTGRES_PASSWORD=secret \
  -e POSTGRES_DB=blog \
  -v blog-db-data:/var/lib/postgresql/data \
  postgres:15

# Wait for it to be ready...

# Start Redis
docker run -d \
  --name blog-cache \
  --network blog-network \
  redis:7

# Start the Flask app
docker run -d \
  --name blog-app \
  --network blog-network \
  -e DATABASE_URL=postgresql://postgres:secret@blog-db:5432/blog \
  -e REDIS_URL=redis://blog-cache:6379 \
  -v $(pwd)/app:/app \
  my-blog-app:latest

# Start nginx
docker run -d \
  --name blog-nginx \
  --network blog-network \
  -p 80:80 \
  -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf \
  nginx:alpine

This works. But look at the problems:

Problem 1: Not repeatable Every time you restart your computer or want to share this with a teammate, you have to run all these commands again. Copy-paste from your notes. Hope you didn’t miss anything.

Problem 2: Order matters The Flask app will fail if PostgreSQL isn’t ready yet. You have to manually wait or add sleep commands. If Redis restarts, the app might not reconnect.

Problem 3: Configuration is scattered Environment variables are on the command line. Volume mounts are hardcoded. If you want to change the PostgreSQL password, you have to find that specific docker run command.

Problem 4: Hard to share Your colleague wants to run the same setup. You send them… what? A shell script? Written instructions? They’re on Windows—$(pwd) doesn’t work the same way.

Problem 5: No lifecycle management Want to stop everything? Four docker stop commands. Want to remove everything? Four docker rm commands. Want to see logs from all services? Multiple terminals with docker logs -f.

Problem 6: Can’t version control commands You can put your Dockerfile and app code in git. But your docker run commands? Those live in a README or a bash script that nobody maintains.

This approach doesn’t scale beyond 2-3 containers.

Engine status: planned. The shell remains visible while the artifact execution is prepared.