Use this as the everyday command reference once a docker-compose.yml already exists, no need to remember raw docker run flags.
Steps
- Start everything defined in the compose file, in the background:
docker compose up -d - Stop and remove the containers (data in named volumes survives this):
docker compose down - Apply a config change (new environment variable, new port mapping):
docker compose down && docker compose up -d - Check what's currently running:
docker compose ps - 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