cli icon indicating copy to clipboard operation
cli copied to clipboard

Feature: docker rm --all --force Command

Open schuerg opened this issue 1 year ago • 2 comments

Description

I’d like to suggest adding an -a, --all option to the docker rm command. With this we could do commands like docker rm --all --force. It would allow us to remove all containers, both running and stopped, with a single command. Currently, we have to stop them first and then remove them, which feels a bit clunky.

Podman has this functionality built in. Adding this option to Docker would streamline the process and improve the user experience.

References

  • https://docs.docker.com/reference/cli/docker/container/rm/
  • https://docs.podman.io/en/latest/markdown/podman-rm.1.html

schuerg avatar Sep 25 '24 11:09 schuerg

related to / (partial) duplicate of;

  • https://github.com/docker/cli/issues/3622
  • https://github.com/docker/cli/issues/3565
  • https://github.com/docker/cli/issues/1679
  • https://github.com/docker/cli/issues/5930
  • https://github.com/docker/cli/pull/3580

I think this one still needs a wider discussion, because these commands were primarily designed to interact on a single containers, or a list of containers provided as argument. Performing batch operations is somewhat conflicting with that design, which is why this was not implemented originally (besides the potential risk of a single flag being a bit of a "foot-gun" and a destructive operation).

thaJeztah avatar Sep 25 '24 11:09 thaJeztah

I find myself doing docker stop $(docker ps -q) and docker rm $(docker ps -aq) probably to the point where I should've created a shell alias by now, so I do think we should look into. Nonetheless, it might make sense to see where we should implement it, as it could make sense to do it engine-side.

laurazard avatar Sep 26 '24 09:09 laurazard

@schuerg @thaJeztah is this issue open to contribute ?

0xV0YD avatar Jan 21 '25 16:01 0xV0YD

+1, I'd love to submit a PR for this

because these commands were primarily designed to interact on a single containers

How about docker container prune --all -f ? (adding the --all flag)

iTrooz avatar Mar 05 '25 18:03 iTrooz