Class: Kamal::Commands::Prune
- Inherits:
-
Base
- Object
- Base
- Kamal::Commands::Prune
show all
- Defined in:
- lib/kamal/commands/prune.rb
Constant Summary
Constants inherited
from Base
Base::DOCKER_HEALTH_LOG_FORMAT, Base::DOCKER_HEALTH_STATUS_FORMAT
Instance Attribute Summary
Attributes inherited from Base
#config
Instance Method Summary
collapse
Methods inherited from Base
#container_id_for, #initialize, #make_directory, #make_directory_for, #remove_directory, #run_over_ssh
Instance Method Details
#app_containers(keep_last: 5) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/kamal/commands/prune.rb', line 16
def app_containers(keep_last: 5)
pipe \
docker(:ps, "-q", "-a", *service_filter, *stopped_containers_filters),
"tail -n +#{keep_last + 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
|
#healthcheck_containers ⇒ Object
23
24
25
|
# File 'lib/kamal/commands/prune.rb', line 23
def healthcheck_containers
docker :container, :prune, "--force", *healthcheck_service_filter
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
|