Class: Kitchen::Driver::Docker

Inherits:
SSHBase
  • Object
show all
Defined in:
lib/kitchen/driver/docker.rb

Overview

Docker driver for Kitchen.

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/kitchen/driver/docker.rb', line 63

def create(state)
  state[:image_id] = build_image(state) unless state[:image_id]
  state[:container_id] = run_container(state) unless state[:container_id]
  state[:hostname] = remote_socket? ? socket_uri.host : 'localhost'
  state[:port] = container_ssh_port(state)
  wait_for_sshd(state[:hostname], nil, :port => state[:port])
end

#default_imageObject



54
55
56
57
# File 'lib/kitchen/driver/docker.rb', line 54

def default_image
  platform, release = instance.platform.name.split('-')
  release ? [platform, release].join(':') : 'base'
end

#default_platformObject



59
60
61
# File 'lib/kitchen/driver/docker.rb', line 59

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

#destroy(state) ⇒ Object



71
72
73
74
75
76
# File 'lib/kitchen/driver/docker.rb', line 71

def destroy(state)
  rm_container(state) if state[:container_id]
  if config[:remove_images] && state[:image_id]
    rm_image(state)
  end
end

#remote_socket?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/kitchen/driver/docker.rb', line 78

def remote_socket?
  config[:socket] ? socket_uri.scheme == 'tcp' : false
end

#verify_dependenciesObject



47
48
49
50
51
52
# File 'lib/kitchen/driver/docker.rb', line 47

def verify_dependencies
  run_command('docker > /dev/null', :quiet => true)
  rescue
    raise UserError,
    'You must first install Docker http://www.docker.io/gettingstarted/'
end