How to use Docker Compose: install Docker, write compose file, up/down, logs, first web+DB stack

Install Compose, define a web+Postgres stack, and manage it with up, down, and logs.

You need a web tier and PostgreSQL on your laptop without fighting host package versions. Docker Compose describes multi-container apps in docker-compose.yml and drives them with one CLI.

Searchers looking for Docker Compose install docker-compose.yml up down logs web database stack usually need Docker + Compose installed, a valid compose file, up/down workflow, logs for debugging, and a working web + database example. Steps follow docs.docker.com.

Install Docker + ComposeWrite compose fileup · logs · first stack

Who Compose is for

01

Full-stack / backend devs

Run API + DB locally the same way teammates do; avoid manual install drift.

02

Ops-curious engineers

Practice up/down/logs/ps before Kubernetes or cloud PaaS.

03

Workshop authors

One compose file bootstraps nginx + Postgres; reset with down -v when needed.

Install Docker and the Compose plugin

  1. 1

    macOS / Windows: Docker Desktop

    Download from https://docs.docker.com/desktop/ (Docker Hub download links redirect there). Install, start Docker Desktop, wait until the engine reports running. Compose V2 ships as docker compose.

  2. 2

    Linux: Docker Engine + compose plugin

    Follow https://docs.docker.com/engine/install/ for your distro, then install the Compose plugin per https://docs.docker.com/compose/install/linux/ (package name often docker-compose-plugin).

  3. 3

    Verify CLI

    Run docker --version and docker compose version. If only hyphenated docker-compose exists, prefer upgrading to the plugin; legacy binary behavior differs slightly.

  4. 4

    Permissions (Linux)

    Without sudo, add your user to the docker group per official post-install steps, then log out/in. Do not chmod /var/run/docker.sock to world-writable.

Write your first docker-compose.yml (web + PostgreSQL)

Create a project folder with docker-compose.yml (filename also accepted: compose.yaml). Example: nginx on port 8080 and PostgreSQL 16 with a named volume:

services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
    volumes:
      - ./html:/usr/share/nginx/html:ro
    depends_on:
      - db
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: devpass
      POSTGRES_DB: appdb
    volumes:
      - db_data:/var/lib/postgresql/data

volumes:
  db_data:

Put a simple html/index.html on the host. Never commit real passwords; use .env for local secrets and add .env to .gitignore (see Docker docs on env files).

Start, stop, and tail logs

CommandActionWhen
docker compose up -dStart detachedFirst bring-up
docker compose psStatus / portsConfirm mapping
docker compose logs -f webFollow logsDebug startup
docker compose stopStop containersPause without removing
docker compose downRemove containers/networkClean shutdown
docker compose pullRefresh imagesBefore upgrades

Verify the web + database stack

  1. 1

    HTTP

    Open http://localhost:8080 — nginx should serve your index.html.

  2. 2

    Database

    docker compose exec db psql -U app -d appdb -c '\dt' checks Postgres inside the container.

  3. 3

    Rebuild after edits

    If you add a build: section later, use docker compose up -d --build.

Compose orchestrates containers on one Docker host; it is not a cloud substitute. Backups, TLS, and scaling live in platform-specific docs.

Once the stack runs locally, open a browser room from the wbroom homepage for whiteboard or voice sync — create and join a room.

Questions worth checking

Compose V2 vs legacy docker-compose?

Modern installs ship docker compose (V2 plugin). Hyphenated docker-compose is the older standalone binary; confirm with docker compose version.

Does docker compose down wipe data?

Named volumes (e.g. db_data) survive a normal down. Use docker compose down -v only when you intend to reset dev data.

Port already in use?

Change the host side in ports (e.g. 8080:80) or inspect with docker compose ps / lsof.

Is this compose file production-ready?

This guide targets local learning: default passwords, no TLS, no backups. Production needs secrets, healthchecks, limits, and pinned image tags per Docker docs.

Start a meeting