Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

The Command

cd /srv/shop
docker compose down

Run it in the folder that holds the project's compose.yaml. Compose stops each service, removes its containers, and removes the networks it created. The services are offline until you start them again with docker compose up -d, which creates new containers. On old installations the same command was written docker-compose down.

What Is Removed and What Stays

ItemPlain down
ContainersRemoved
Project networksRemoved
Named volumesKept
Anonymous volumesKept, but not reused
Bind-mounted foldersKept
ImagesKept
External networksNever removed
External volumesNever removed

Anonymous volumes have no stable name, so the next up creates fresh ones and does not mount the old ones again. Data that must survive belongs in a named volume or a bind mount; see Docker volumes vs bind mounts.

down vs stop

CommandEffect
docker compose stopStops, keeps containers
docker compose downStops, removes containers

Use stop for a short pause: docker compose start resumes the same containers. Use down when you want a clean start or before you remove the project. Anything written inside a container's own file system and not in a volume is lost with down.

The -v Option Deletes Your Data

With -v, Compose also deletes the named volumes declared in the file and the anonymous volumes of the containers. For a database service, that is the database itself. There is no undo. Use it only for test projects, or after a backup that you have checked:

  1. List the project's volumes: docker volume ls shows names that start with the project name.
  2. Back up each volume you need, or take a server snapshot; see snapshot vs backup.
  3. Then run the command.
docker compose down -v

Remove Images Too

docker compose down --rmi local
docker compose down --rmi all

--rmi local removes only images that have no custom tag, which are usually images Compose built for the project. --rmi all removes every image the services use. Both are safe for your data but mean a new pull or build on the next start. For a wider cleanup, see how to remove Docker images.

Orphan Containers

If you rename or delete a service in compose.yaml, its old container is left running as an orphan, and Compose warns about it. Remove such containers with:

docker compose down --remove-orphans

The same option works with up -d.

Run It for the Right Project

Compose finds the project by the folder you are in. The project name defaults to the folder name, and every container, network, and volume carries it. Running down in the wrong folder affects the wrong project, so check first:

docker compose ls
docker compose -f /srv/shop/compose.yaml down
docker compose -p shop down

docker compose ls lists the running projects on the server (add -a to include stopped ones), -f names a file, and -p names a project directly. If a project was started with -p, stop it with the same name.

Timeouts and Logs

down gives each container 10 seconds to stop before it is killed. Give slow services more time with -t 60. If something fails after the next start, read the output with docker logs or docker compose logs.

Was this answer helpful?
Loading...