bash yaml 149 lines · 2 tabs

Docker Compose for multi-container applications

Ryan Nakamura Feb 2026
2 tabs
#!/bin/bash
# Docker Compose commands

# Start all services
docker compose up -d

# Start with build
docker compose up -d --build

# Start specific services
docker compose up -d app db

# Start with profiles
docker compose --profile workers up -d

# View logs
docker compose logs -f app
docker compose logs --tail=100 db

# Scale services
docker compose up -d --scale worker=3

# Execute commands in running service
docker compose exec app /bin/sh
docker compose exec db psql -U postgres myapp

# Stop services
docker compose stop
docker compose down              # Stop and remove containers
docker compose down -v           # Also remove volumes
docker compose down --rmi all    # Also remove images

# Check status
docker compose ps
docker compose top

# Override for development
# docker-compose.override.yml is auto-loaded
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
2 files · bash, yaml Explain with highlit

Docker Compose orchestrates multi-container applications with a single YAML file. The docker-compose.yml defines services, networks, and volumes declaratively. Each service maps to a container with its own image, ports, environment, and dependencies. The depends_on directive controls startup order. Named volumes persist data across container restarts. Custom networks isolate service communication. Environment variables can be loaded from .env files. The build key builds images from local Dockerfiles. Health checks ensure services are ready before dependents start. Use docker compose up -d to start all services, docker compose down to stop them. Profiles group optional services. Compose is essential for local development environments that mirror production topology.


Related snips

javascript
// Express app with health checks and graceful shutdown
const express = require('express');
const { createServer } = require('http');

const app = express();
const server = createServer(app);

Container health checks and graceful shutdown patterns

docker kubernetes health-checks
by Ryan Nakamura 1 tab
javascript
// k6 Load Test Configuration
// Run: k6 run load-test.js --env BASE_URL=https://api.example.com

import http from 'k6/http';
import { check, sleep, group } from 'k6';
import { Rate, Trend, Counter } from 'k6/metrics';

Load testing APIs with k6 for performance validation

k6 load-testing performance
by Ryan Nakamura 1 tab
hcl
# Using the module

module "api_service" {
  source = "./modules/ecs_service"

  service_name       = "api"

Terraform modules for reusable infrastructure

terraform modules iac
by Ryan Nakamura 2 tabs
bash
#!/usr/bin/env bash
set -euo pipefail

# ==========================================================
# Production Incident Response Runbook
# ==========================================================

Incident response runbook and diagnostic scripts

incident-response sre production
by Ryan Nakamura 1 tab
yaml
- name: Build image
  run: docker build -t app:${{ github.sha }} .

- name: Scan image
  uses: aquasecurity/trivy-action@0.24.0
  with:

Trivy image scanning in pull request pipelines

trivy containers ci
by Kai Nakamura 1 tab
bash
#!/usr/bin/env bash
# Docker Networking Modes & Configuration

# === List networks ===
docker network ls
docker network inspect bridge

Docker networking: bridge, host, and overlay networks

docker networking containers
by Ryan Nakamura 1 tab

Share this code

Here's the card — post it anywhere.

Docker Compose for multi-container applications — share card
Link copied