Retain a fixed number of containers when pruning

Time based container and image retention can have variable space
requirements depending on how often we deploy.

- Only prune stopped containers, retaining the 5 newest
- Then prune dangling images so we only keep images for the retained
containers.
This commit is contained in:
Donal McBreen
2023-05-01 14:48:19 +01:00
parent 54881a0298
commit 971a91da15
4 changed files with 18 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ class Mrsk::Cli::Prune < Mrsk::Cli::Base
end
end
desc "images", "Prune unused images older than 7 days"
desc "images", "Prune dangling images"
def images
with_lock do
on(MRSK.hosts) do
@@ -17,7 +17,7 @@ class Mrsk::Cli::Prune < Mrsk::Cli::Base
end
end
desc "containers", "Prune stopped containers older than 3 days"
desc "containers", "Prune all stopped containers, except the last 5"
def containers
with_lock do
on(MRSK.hosts) do