Starting and Stopping Services: compose up and compose down
With your docker-compose.yml file ready, you can manage all services with two fundamental commands.
1. Starting the Stack
To start all services defined in your Compose file:
# Start all services in the background (detached mode)
docker compose up -dOn the first run, Docker Compose will:
- Create all declared networks.
- Create all declared volumes.
- Pull or build images for each service.
- Start containers in the correct order based on
depends_onrules.
Rebuilding Images
If you modify a Dockerfile, you must tell Compose to rebuild the image before starting:
# Force rebuild all images before starting containers
docker compose up -d --build2. Stopping the Stack
To stop and remove all running containers and networks:
# Stop and remove all containers and networks
docker compose downTo also delete the named volumes (database data will be erased):
# Remove containers, networks, and named volumes
docker compose down -v3. Managing Individual Services
You can control a single service within the stack without affecting the others:
# Start only the api service
docker compose up -d api
# Stop only the cache service
docker compose stop cache
# Restart a single service
docker compose restart apiPublished on Last updated: