Class: Kitchen::Driver::Docker

Inherits:
Base
  • Object
show all
Includes:
Kitchen::Docker::Helpers::CliHelper, Kitchen::Docker::Helpers::ContainerHelper, ShellOut
Defined in:
lib/kitchen/driver/docker.rb

Overview

Docker driver for Kitchen.

Author:

Instance Method Summary collapse

Methods included from Kitchen::Docker::Helpers::ContainerHelper

#container_env_variables, #container_exec, #container_exists?, #container_ip_address, #copy_file_to_container, #create_dir_on_container, #dockerfile_path, #dockerfile_proxy_config, #dockerfile_template, #parse_container_id, #remote_socket?, #remove_container, #replace_env_variables, #run_container, #socket_uri

Methods included from Kitchen::Docker::Helpers::CliHelper

#build_copy_command, #build_env_variable_args, #build_exec_command, #build_powershell_command, #build_run_command, #config_to_options, #dev_null, #docker_command, #docker_shell_opts, #run_command

Instance Method Details

#create(state) ⇒ Object


123
124
125
126
127
# File 'lib/kitchen/driver/docker.rb', line 123

def create(state)
  container.create(state)

  wait_for_transport(state)
end

#default_imageObject


141
142
143
144
145
146
147
# File 'lib/kitchen/driver/docker.rb', line 141

def default_image
  platform, release = instance.platform.name.split('-')
  if platform == 'centos' && release
    release = 'centos' + release.split('.').first
  end
  release ? [platform, release].join(':') : platform
end

#default_platformObject


149
150
151
# File 'lib/kitchen/driver/docker.rb', line 149

def default_platform
  instance.platform.name.split('-').first
end

#destroy(state) ⇒ Object


129
130
131
# File 'lib/kitchen/driver/docker.rb', line 129

def destroy(state)
  container.destroy(state)
end

#verify_dependenciesObject


117
118
119
120
121
# File 'lib/kitchen/driver/docker.rb', line 117

def verify_dependencies
  run_command("#{config[:binary]} >> #{dev_null} 2>&1", quiet: true, use_sudo: config[:use_sudo])
rescue
  raise UserError, 'You must first install the Docker CLI tool https://www.docker.com/get-started'
end

#wait_for_transport(state) ⇒ Object


133
134
135
136
137
138
139
# File 'lib/kitchen/driver/docker.rb', line 133

def wait_for_transport(state)
  if config[:wait_for_transport]
    instance.transport.connection(state) do |conn|
      conn.wait_until_ready
    end
  end
end