Back to roadmaps docker-compose Course

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 -d

On the first run, Docker Compose will:

  1. Create all declared networks.
  2. Create all declared volumes.
  3. Pull or build images for each service.
  4. Start containers in the correct order based on depends_on rules.

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 --build

2. Stopping the Stack

To stop and remove all running containers and networks:

# Stop and remove all containers and networks
docker compose down

To also delete the named volumes (database data will be erased):

# Remove containers, networks, and named volumes
docker compose down -v

3. 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 api
Published on Last updated: