Skip to content

[Feature] "down --all" to include all containers regardless of active profiles. #13647

@jusito

Description

@jusito

Description

I would like an option to have a single command removing all containers, volumes, orphans, network for a given compose file. I thought docker compose down -v -t 0 --remove-orphans does this but as experienced it does not work with profiles. #13027

Example in which this would be useful:

  1. Setup:
services:
  foo:
    image: alpine
    command: tail -f /dev/null
    stop_grace_period: 1s

  bar:
    profiles:
    - manual
    depends_on:
      - foo
    image: alpine
    command: tail -f /dev/null
    stop_grace_period: 1s
  1. commands:
  • docker compose up -d bar
  • docker compose down -t 0 -v --remove-orphans
  1. I expected that all containers for this compose project are wiped. But container bar is still there, also blocking network removal and could also block volumes.

What is the issue with this?
There is always additional knowledge required to wipe a running compose project. E.g. for a random project maybe having different profiles in it you would need something like COMPOSE_PROFILES=$(docker compose config --profiles | tr '\n' ',') docker compose down -t 0 -v --remove-orphans which is the only way of truly resetting it in a generic way.

Proposing --all for down which including all containers for the compose project, like: docker compose down -t 0 -v --all, all should include orphans by default. This would be consistent with other commands which provide --all for docker / docker compose e.g. ps or prune, so I already expected it to exist for down.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions