Class: Kitchen::Driver::Docker
- Inherits:
-
SSHBase
- Object
- SSHBase
- Kitchen::Driver::Docker
- Defined in:
- lib/kitchen/driver/docker.rb
Overview
Docker driver for Kitchen.
Instance Method Summary collapse
- #create(state) ⇒ Object
- #default_image ⇒ Object
- #default_platform ⇒ Object
- #destroy(state) ⇒ Object
- #remote_socket? ⇒ Boolean
- #verify_dependencies ⇒ Object
Instance Method Details
#create(state) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/kitchen/driver/docker.rb', line 69 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_image ⇒ Object
60 61 62 63 |
# File 'lib/kitchen/driver/docker.rb', line 60 def default_image platform, release = instance.platform.name.split('-') release ? [platform, release].join(':') : platform end |
#default_platform ⇒ Object
65 66 67 |
# File 'lib/kitchen/driver/docker.rb', line 65 def default_platform instance.platform.name.split('-').first end |
#destroy(state) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/kitchen/driver/docker.rb', line 77 def destroy(state) rm_container(state) if container_exists?(state) if config[:remove_images] && state[:image_id] rm_image(state) end end |
#remote_socket? ⇒ Boolean
84 85 86 |
# File 'lib/kitchen/driver/docker.rb', line 84 def remote_socket? config[:socket] ? socket_uri.scheme == 'tcp' : false end |
#verify_dependencies ⇒ Object
53 54 55 56 57 58 |
# File 'lib/kitchen/driver/docker.rb', line 53 def verify_dependencies run_command("#{config[:binary]} > /dev/null", :quiet => true) rescue raise UserError, 'You must first install the Docker CLI tool http://www.docker.io/gettingstarted/' end |