What docker compose up does
Select an icon to see what it is.
Step 6 of 6
ps and down use the labels
docker compose ps asks dockerd for containers with the label com.docker.compose.project=shop. docker compose down stops and removes those containers and then the network. The volume is kept unless you add -v.
$ docker compose down PrevNext
GET /v1.45/containers/json
{"filters": {"label": ["com.docker.compose.project=shop"]}}
Try it yourself
Write the file, start the project, look at it, and take it down. Note that docker compose, with a space, is the current command. The older docker-compose program is the previous version, and Compose also accepts the older file name docker-compose.yml.
$ cat > compose.yaml <<'EOF' name: shop services: web: image: nginx ports: - "8080:80" networks: default: ipv4_address: 172.18.0.2 api: image: traefik/whoami command: ["--port", "3000"] networks: default: ipv4_address: 172.18.0.3 db: image: postgres:17 environment: POSTGRES_PASSWORD: example volumes: - pgdata:/var/lib/postgresql/data networks: default: ipv4_address: 172.18.0.4 volumes: pgdata: networks: default: name: shop-net ipam: config: - subnet: 172.18.0.0/16 EOF$ docker compose up -d$ docker compose ps$ docker inspect --format '{{json .Config.Labels}}' shop-web-1$ docker compose down