New batchZero to DevOps starts 29 Nov · limited seatsReserve your seat
Cheat sheetsDockerDocker
ProSheet 10 of 11

Docker Compose

A comprehensive developer cheatsheet covering Docker Compose fundamentals, featuring essential CLI commands and operational workflows for defining, starting, stopping, scaling, and debugging multi-container Docker applications.

Understanding Docker Compose

What is Docker Compose?

Docker Compose is a tool for defining and running multi-container Docker applications. Using a single YAML file (docker-compose.yml), you can configure all your application's services, networks, and volumes.

Common Commands Overview

CommandPurpose
upStart services
downStop services
psList services
logsView logs
execExecute commands
buildBuild images
restartRestart services
pullPull images
stopStop services
startStart services
rmRemove services

Sample docker-compose.yml

yaml
version: '3.8'

services:
  web:
    build: .
    ports:
      - "8080:80"
    depends_on:
      - db
      - redis
    environment:
      - DB_HOST=db
      - REDIS_HOST=redis
    volumes:
      - ./app:/app
      - /app/node_modules

  db:
    image: postgres:15
    environment:
      - POSTGRES_USER=myuser
      - POSTGRES_PASSWORD=mypassword
      - POSTGRES_DB=mydb
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"

volumes:
  postgres_data:

The rest of this sheet is locked7 Pro sheets unlock together, across every toolEveryPro sheet, every toolLifetimeone payment, no renewalNewsheets included as they shipOne-time payment · lifetime access