class Kitchen::Docker::Container
Public Class Methods
new(config)
click to toggle source
# File lib/kitchen/docker/container.rb, line 27 def initialize(config) @config = config end
Public Instance Methods
create(state)
click to toggle source
# File lib/kitchen/docker/container.rb, line 31 def create(state) if container_exists?(state) info("Container ID #{state[:container_id]} already exists.") elsif !container_exists?(state) && state[:container_id] raise ActionFailed, "Container ID #{state[:container_id]} was found in the kitchen state data, "\ 'but the container does not exist.' end state[:username] = @config[:username] end
destroy(state)
click to toggle source
# File lib/kitchen/docker/container.rb, line 42 def destroy(state) info("[Docker] Destroying Docker container #{state[:container_id]}") if state[:container_id] remove_container(state) if container_exists?(state) if @config[:remove_images] && state[:image_id] remove_image(state) if image_exists?(state) end end
hostname(state)
click to toggle source
# File lib/kitchen/docker/container.rb, line 51 def hostname(state) hostname = 'localhost' if remote_socket? hostname = socket_uri.host elsif @config[:use_internal_docker_network] hostname = container_ip_address(state) end hostname end
upload(locals, remote)
click to toggle source
# File lib/kitchen/docker/container.rb, line 63 def upload(locals, remote) files = locals files = Array(locals) unless locals.is_a?(Array) files.each do |file| copy_file_to_container(@config, file, remote) end files end