Class: Kamal::Commands::Prune

Inherits:
Base
  • Object
show all
Defined in:
lib/kamal/commands/prune.rb

Constant Summary

Constants inherited from Base

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, #remove_file, #run_over_ssh

Constructor Details

This class inherits a constructor from Kamal::Commands::Base

Instance Method Details

#app_containers(retain:) ⇒ Object



16
17
18
19
20
21
# File 'lib/kamal/commands/prune.rb', line 16

def app_containers(retain:)
  pipe \
    docker(:ps, "-q", "-a", *service_filter, *stopped_containers_filters),
    "tail -n +#{retain + 1}",
    "while read container_id; do docker rm $container_id; done"
end

#dangling_imagesObject



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_imagesObject



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