← Back to Notes
DockerJuly 2, 2026

How to Start, Stop, and Restart Docker Containers the Right Way

Use this as the everyday command reference once a docker-compose.yml already exists, no need to remember raw docker run flags.

Steps

  1. Start everything defined in the compose file, in the background:
    docker compose up -d
    
  2. Stop and remove the containers (data in named volumes survives this):
    docker compose down
    
  3. Apply a config change (new environment variable, new port mapping):
    docker compose down && docker compose up -d
    
  4. Check what's currently running:
    docker compose ps
    
  5. See logs from a running container, useful when something fails silently:
    docker compose logs -f
    

Gotcha

docker compose down is not the same as deleting your data, named volumes persist through it. What actually deletes volumes is adding the -v flag: docker compose down -v. Easy to do by habit from a different project and accidentally wipe a database.

Quick reference

docker compose up -d       # start
docker compose down        # stop (data persists)
docker compose down -v     # stop AND wipe volumes
docker compose ps          # status
docker compose logs -f     # live logs