Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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 this issue Feb 25, 2024 · 3 comments
Assignees
Labels
community_new New idea raised by a community contributor

Comments

@AleixMT
Copy link

AleixMT commented Feb 25, 2024

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 AleixMT added the community_new New idea raised by a community contributor label Feb 25, 2024
@AleixMT
Copy link
Author

AleixMT commented Feb 25, 2024

I would love to contribute to implement this feature

@AleixMT
Copy link
Author

AleixMT commented Feb 29, 2024

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

@AleixMT
Copy link
Author

AleixMT commented Jun 5, 2024

If anyone is wondering, I am implementing this feature, even though I must say this is my first time working with Go, so I am learning it as part of this process. This is the reason why I am taking so long.

If anyone would like to give me a little feedback on my idea, or hinting me where to find the relevant parts of the source code, I would be very grateful. Thank you for your pattience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_new New idea raised by a community contributor
Projects
None yet
Development

No branches or pull requests

2 participants