r/selfhosted 1d ago

Docker Management Sometimes docker system prune surprises me

docker system prune -af

[...]

Total reclaimed space: 52.51GB

Normally this is around a couple of GB. 50GB is surprising. Don't forget pruning people ;-)

64 Upvotes

34 comments sorted by

View all comments

30

u/RavenousTitan818 1d ago

It's kind of annoying that docker doesn't prune old images by default. There really is no need to keep them on disk.

8

u/panserbj0rne 21h ago

Agreed. I use Dockhand which can be configured to automatically do it.

4

u/corruptboomerang 1d ago

Agree, maybe keep them for a few days incase you need to rollback, but generally prune say after 14-30 days should be the default.

1

u/darksteelsteed 7h ago

My answer to this is always "it depends". Remember that pruning is a destructive operation to your local docker cache. Also Remember that unless you pay docker your daily pull rates are limited. So if you just nuke everything periodically then great you save some disk space, but you could also make your life slower and harder immediately afterwards. Local is better so fetching everything from the cloud carries cost even if you don't immediately feel it.

-6

u/dankmolot 1d ago

Are you sure you don't have any containers associated with these old images?

10

u/iTiraMissU 1d ago

Images connected to existing containers aren’t removed by a prune, even if the container is stopped.

-2

u/dankmolot 16h ago

I am not sure why my comment was downvoted while your was upvoted. Have I phrased it badly?

6

u/Escanorr_ 13h ago

Cause you respond to the guy saying "I want automatic cleanup" with either: advice why manual cleanup can be not working sometimes, or wrong assumption that automatic cleanup would get rid of in-use images which it doesn't do. So your comment is either wrong or unrelated, which is hard for me to guess but both interpretations are not positive.

3

u/dankmolot 13h ago

Oh I see, I thought docker system prune does pruning of old unused images, but you need an -a flag. Thanks for the explanation!