docker / roadmap

Welcome to the Public Roadmap for All Things Docker! We welcome your ideas.
https://github.com/docker/roadmap/projects/1
Creative Commons Zero v1.0 Universal
1.45k stars 244 forks source link

[FEATURE REQUEST] `docker system prune --all` or equivalent command to remove all docker data (containers, volumes, networks, images and cached layers) #617

Open AleixMT opened 2 months ago

AleixMT commented 2 months ago

Tell us about your request I would like to see a single command in the docker CLI that stops all containers, removes all images, caché layers, volumes and networks at once, so the environment in completely clean and empty as the first time that docker is installed.

Which service(s) is this request for? This request is for the docker CLI.

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? The problem that I am trying to solve is to reset the state of docker to the state that it has when it is installed with a simple and handy command in the docker CLI.

I am always frustrated when I want to delete all docker content and I need to type many commands to do so.

Sure, I can have a script that does it too as a one-liner, but then I need to worry about that script.

Are you currently working around the issue? Yes. In this GitHub Gist there are many options to work around the issue.

Particularly, this is the one-liner command that I use to work around the issue:

docker stop $(docker ps -qa); docker rm $(docker ps -qa); docker rmi -f $(docker images -qa); docker volume rm $(docker volume ls -q); docker network rm $(docker network ls -q)

Honors to @acjohnson for the shell one-liner command.

Additional context

This is a quote from @Maxzor in the GitHub Gist that I posted in the previous section:

Shell scripts are damn ugly. But shell is so powerful 🙃 Why is rm -rf --all not in the docker binary lol... Readable bash script at https://gist.github.com/Maxzor/6a3ca2c5c1c28af583711abc8e5fda01

I wonder if maybe this is not in the docker binary because of its destructive potential.

Anyway, I agree because I think this should be in the docker binary in order to avoid having to mess up with shell commands to do an action that is purely related to Docker.

AleixMT commented 2 months ago

I would love to contribute to implement this feature

AleixMT commented 2 months ago

Also notice that podman has the exact equivalent feature: https://docs.podman.io/en/stable/markdown/podman-system-reset.1.html