Docker and Kubernetes

Docker Compose: start, stop, rebuild and logs

The everyday Docker Compose commands, run from the folder with docker-compose.yml.

Fill these in once
  1. Start everything in the background
    Terminal
    docker compose up -d
  2. Start only some services
    Terminal
    docker compose up -d web
  3. Rebuild after changing code or the Dockerfile
    Terminal
    docker compose up -d --build
  4. Follow a service's logs
    Terminal
    docker compose logs -f web

    Press Ctrl + C to stop following.

  5. Stop and remove everything
    Terminal
    docker compose down

    Add -v to also delete the volumes (and their data).

Check it worked

  1. See what's running
    Terminal
    docker compose ps
  1. Start everything in the background
    Terminal · Ubuntu / Debian
    docker compose up -d
  2. Start only some services
    Terminal · Ubuntu / Debian
    docker compose up -d web
  3. Rebuild after changing code or the Dockerfile
    Terminal · Ubuntu / Debian
    docker compose up -d --build
  4. Follow a service's logs
    Terminal · Ubuntu / Debian
    docker compose logs -f web

    Press Ctrl + C to stop following.

  5. Stop and remove everything
    Terminal · Ubuntu / Debian
    docker compose down

    Add -v to also delete the volumes (and their data).

Check it worked

  1. See what's running
    Terminal · Ubuntu / Debian
    docker compose ps
  1. Start everything in the background
    PowerShell
    docker compose up -d
  2. Start only some services
    PowerShell
    docker compose up -d web
  3. Rebuild after changing code or the Dockerfile
    PowerShell
    docker compose up -d --build
  4. Follow a service's logs
    PowerShell
    docker compose logs -f web

    Press Ctrl + C to stop following.

  5. Stop and remove everything
    PowerShell
    docker compose down

    Add -v to also delete the volumes (and their data).

Check it worked

  1. See what's running
    PowerShell
    docker compose ps