Docker Compose has two important commands — up and down.
up)docker compose -f mongodb.yaml up -d-f specifies the file nameup means create and start all containers defined in the file-d runs everything in detached mode (in background)When we execute the command:
Docker Compose performs the following steps:
test-app-default)If our file contains:
Then Docker Compose will:
We may see a warning like:
the version attribute is obsoleteThis happens in newer versions of Docker Compose.
You can:
version field from the YAML filedown)Whenever we want to permanently delete all containers defined in the file:
docker compose -f mongodb.yaml downDocker Compose performs cleanup automatically:
| Command | Result |
|---|---|
up -d | Creates and runs containers |
down | Stops and deletes containers + network |
docker compose up -d → Starts the full application stackdocker compose down → Completely removes the stack