Day 6: Unleashing Docker Compose Magic for Multi-Container Awesomeness!

Usman JapUsman Jap
3 min read

Day 6 kicked off Week 2 with a bang, diving into Docker Compose to orchestrate multi-container apps like a maestro. I spun up a WordPress site, flexed Compose commands, and sniffed out 2025 trends on X. Buckle up for this orchestration adventure!

Kicking Off with Docker Compose

Day 6 was all about Docker Compose, the tool that makes running multiple containers feel like a breeze. I started by ensuring Compose was ready on my Ubuntu system:

bash

docker-compose --version

It was good to go, but if you need it, grab it with:

bash

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Compose lets you define apps in a docker-compose.yml file, handling services, networks, and volumes like a pro. Grok summed it up in 50 words: “Docker Compose orchestrates multi-container apps via YAML, simplifying DevOps workflows.”

Building a WordPress App

I created a wordpress-app directory and crafted a docker-compose.yml:

bash

mkdir wordpress-app
cd wordpress-app
nano docker-compose.yml

Here’s the magic:

yaml

version: '3.8'
services:
  db:
    image: mysql:8
    volumes:
      - db-data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: rootpass
      MYSQL_DATABASE: wordpress
    networks:
      - app-network
  wordpress:
    image: wordpress:latest
    depends_on:
      - db
    ports:
      - "8085:80"
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: rootpass
      WORDPRESS_DB_NAME: wordpress
    networks:
      - app-network
volumes:
  db-data:
networks:
  app-network:
    driver: bridge

This defines a MySQL (db) and WordPress (wordpress) service, linked via app-network, with a volume (db-data) for persistence. The depends_on ensures db starts first, and environment variables connect WordPress to MySQL.

I fired it up:

bash

docker-compose up -d

Checked the status:

bash

docker-compose ps

Both containers were Up. I hit http://localhost:8085 in a browser—WordPress setup page, ready to roll! I verified the database:

bash

docker exec -it $(docker-compose ps -q db) mysql -uroot -prootpass -e "SHOW DATABASES;"

wordpress was there. I stopped it with:

bash

docker-compose down

Mastering Compose Commands

I got hands-on with Compose commands:

  • docker-compose logs wordpress: Peeked at WordPress logs for debugging.

  • docker-compose stop: Paused services.

  • docker-compose start: Restarted them.

  • docker-compose down --volumes: Nuked everything, including volumes.

Grok explained docker-compose ps fields in 100 words: Name (e.g., wordpress-app_db_1), Command, State (e.g., Up), and Ports (e.g., 0.0.0.0:8085->80/tcp). This helped me confirm my app was running smoothly.

Mini-Project: Simple Compose App

For extra practice, I built a lightweight app:

bash

mkdir simple-app
cd simple-app
nano docker-compose.yml

yaml

version: '3.8'
services:
  web:
    image: nginx:latest
    ports:
      - "8086:80"
    networks:
      - simple-net
  redis:
    image: redis:latest
    networks:
      - simple-net
networks:
  simple-net:
    driver: bridge

Ran it:

bash

docker-compose up -d

Checked http://localhost:8086—Nginx’s welcome page! Stopped it:

bash

docker-compose down

Grok Dives into Compose

Grok was my wingman, tackling prompts like:

  • “Explain how Docker Compose integrates with Kubernetes in 150 words, with a 2025 example.” Answer: Compose converts to Kubernetes manifests via Kompose. A 2025 IoT startup tests an MQTT app locally with Compose, then scales it on EKS.

  • “Describe a real-world Docker Compose use case in 2025 in 100 words.” A fintech startup uses Compose for a Node.js/PostgreSQL/Redis payment app, scaling to Kubernetes.

Using DeepSearch, I found an X post from @ThePracticalDev (January 7, 2025) on scaling Compose apps, with 3,875 views. Summary: “Compose streamlines local multi-container setups, scaling to production with Kubernetes for 2025’s microservices.”

I used think mode for: “Step-by-step, how does Docker Compose manage dependencies?” Grok explained: depends_on sets startup order, shared networks enable DNS, and environment variables link services like WORDPRESS_DB_HOST: db.

0
Subscribe to my newsletter

Read articles from Usman Jap directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Usman Jap
Usman Jap