Module: Infopen::Docker::Lifecycle
- Includes:
- Error
- Defined in:
- lib/docker/lifecycle.rb
Overview
This module contains tests about docker images and containers lifecycle
Class Method Summary collapse
-
.remove_image_and_its_containers(image_obj) ⇒ Object
Remove image and its containers.
Class Method Details
.remove_image_and_its_containers(image_obj) ⇒ Object
Remove image and its containers.
Raise an ArgumentError if bad param number
Raise an Infopen::Docker::ArgumentError if param is not a Docker::Image instance
Raise an Infopen::Docker::ImageError if image not exists
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/docker/lifecycle.rb', line 20 def self.remove_image_and_its_containers(image_obj) # Check param unless image_obj.is_a?(Docker::Image) raise ArgumentError, "Expected a Docker::Image, got: #{image_obj}." end # Get and remove all containers linked to image get_containers_from_image_id(image_obj.id).each do |container| Docker::Container.get(container.id).remove(:force => true) end # Remove image image_obj.remove(:force => true) end |