Class: Kamal::Commands::Prune
Constant Summary
Constants inherited from Base
Base::DOCKER_HEALTH_STATUS_FORMAT, Base::NO_HEALTHCHECK
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#app_containers(retain:, role:) ⇒ Object
Scoped to one role so a busy sibling role cannot push another role's newest container past the retain window.
- #dangling_images ⇒ Object
- #tagged_images ⇒ Object
Methods inherited from Base
#container_id_for, #ensure_docker_installed, #initialize, #make_directory, #make_directory_for, #read_file, #remove_directory, #remove_file, #run_over_ssh
Constructor Details
This class inherits a constructor from Kamal::Commands::Base
Instance Method Details
#app_containers(retain:, role:) ⇒ Object
Scoped to one role so a busy sibling role cannot push another role's newest
container past the retain window. That matters beyond disk hygiene: a
container kamal-proxy has put to sleep is exited, so it is a removal
candidate, and once it is gone every wake 404s. With retain >= 1 a role's
newest container always survives, and the slept one is always the newest —
sleeping happens to the current release.
22 23 24 25 26 27 |
# File 'lib/kamal/commands/prune.rb', line 22 def app_containers(retain:, role:) pipe \ docker(:ps, "-q", "-a", *service_filter, *destination_filter, *role_filter(role), *stopped_containers_filters), "tail -n +#{retain + 1}", "while read container_id; do docker rm $container_id; done" end |
#dangling_images ⇒ Object
5 6 7 |
# File 'lib/kamal/commands/prune.rb', line 5 def dangling_images docker :image, :prune, "--force", "--filter", "label=service=#{config.service}" end |
#tagged_images ⇒ Object
9 10 11 12 13 14 |
# File 'lib/kamal/commands/prune.rb', line 9 def tagged_images pipe \ docker(:image, :ls, *service_filter, "--format", "'{{.ID}} {{.Repository}}:{{.Tag}}'"), grep("-v -w \"#{active_image_list}\""), "while read image tag; do docker rmi $tag; done" end |