docker / cli

The Docker CLI
Apache License 2.0
4.97k stars 1.95k forks source link

Feature: docker rm --all --force Command #5479

Open schuerg opened 2 months ago

schuerg commented 2 months ago

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

thaJeztah commented 2 months ago

related to / (partial) duplicate of;

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).

laurazard commented 2 months ago

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.