Class: Kitchen::Driver::Docker
- Inherits:
-
SSHBase
- Object
- SSHBase
- Kitchen::Driver::Docker
- Defined in:
- lib/kitchen/driver/docker.rb
Overview
Docker driver for Kitchen.
Constant Summary collapse
- MUTEX_FOR_SSH_KEYS =
Mutex.new
Instance Method Summary collapse
- #create(state) ⇒ Object
- #default_image ⇒ Object
- #default_platform ⇒ Object
- #destroy(state) ⇒ Object
- #dev_null ⇒ Object
- #remote_socket? ⇒ Boolean
- #verify_dependencies ⇒ Object
Instance Method Details
#create(state) ⇒ Object
107 108 109 110 111 112 113 114 115 |
# File 'lib/kitchen/driver/docker.rb', line 107 def create(state) generate_keys state[:ssh_key] = config[:private_key] 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]) if config[:wait_for_sshd] end |
#default_image ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/kitchen/driver/docker.rb', line 95 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_platform ⇒ Object
103 104 105 |
# File 'lib/kitchen/driver/docker.rb', line 103 def default_platform instance.platform.name.split('-').first end |
#destroy(state) ⇒ Object
117 118 119 120 121 122 |
# File 'lib/kitchen/driver/docker.rb', line 117 def destroy(state) rm_container(state) if container_exists?(state) if config[:remove_images] && state[:image_id] rm_image(state) end end |
#dev_null ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/kitchen/driver/docker.rb', line 86 def dev_null case RbConfig::CONFIG["host_os"] when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ "NUL" else "/dev/null" end end |
#remote_socket? ⇒ Boolean
124 125 126 |
# File 'lib/kitchen/driver/docker.rb', line 124 def remote_socket? config[:socket] ? socket_uri.scheme == 'tcp' : false end |
#verify_dependencies ⇒ Object
79 80 81 82 83 84 |
# File 'lib/kitchen/driver/docker.rb', line 79 def verify_dependencies run_command("#{config[:binary]} >> #{dev_null} 2>&1", :quiet => true) rescue raise UserError, 'You must first install the Docker CLI tool http://www.docker.io/gettingstarted/' end |