Merge pull request #650 from basecamp/retained-containers

Config the number of containers to keep
This commit is contained in:
Donal McBreen
2024-03-04 12:05:35 +00:00
committed by GitHub
6 changed files with 42 additions and 7 deletions

View File

@@ -13,10 +13,10 @@ class Kamal::Commands::Prune < Kamal::Commands::Base
"while read image tag; do docker rmi $tag; done"
end
def app_containers(keep_last: 5)
def app_containers(retain:)
pipe \
docker(:ps, "-q", "-a", *service_filter, *stopped_containers_filters),
"tail -n +#{keep_last + 1}",
"tail -n +#{retain + 1}",
"while read container_id; do docker rm $container_id; done"
end