Hacker News new | ask | show | jobs
by joekrill 3432 days ago
But that's really what `docker rm` is for, isn't it? I mean, if you want to only delete specific containers, use that. Prune has a specific purpose, which I think is very clear. If you're running the command, you (presumably) know what it should be doing.

I suppose you could argue it might be nice to be able to do something like `docker container prune startsWith*` or something similar. But on the other hand, that functionality is already available -- just use `docker rm` with xargs or something.

1 comments

But the thing people complain most isn't because they want to delete everything but because they need docker rm, xargs and complex bash foo to delete the containers and images they don't need.

For example I want to delete all old and all untagged versions of an image. I want to delete all stopped containers that use a specific image, or that were created more than two weeks ago. I want to delete all images starting with test.

Nuke everything? Not so much and to be honest this would be the easiest even with xargs and docker rm.

fyi, you do not need xargs.

`docker rm $(docker ps -q --filter blash)`

But agree, `prune` is currently sledge hammer and needs some refinement. It's not about not being well thought out, it's about getting something out there that can be built on top of.

Thanks, it was too long since I used filter and it wasn't that interesting. Seems much better now!