Class: Kitchen::Driver::Docker
- Inherits:
-
SSHBase
- Object
- SSHBase
- Kitchen::Driver::Docker
- Defined in:
- lib/kitchen/driver/docker.rb
Overview
Docker driver
Instance Method Summary collapse
- #create(state) ⇒ Object
- #default_container_name ⇒ Object
- #default_image ⇒ Object
- #default_platform ⇒ Object
- #destroy(state) ⇒ Object
-
#initialize(*args) ⇒ Docker
constructor
A new instance of Docker.
Constructor Details
#initialize(*args) ⇒ Docker
Returns a new instance of Docker.
51 52 53 54 55 56 57 |
# File 'lib/kitchen/driver/docker.rb', line 51 def initialize(*args) super(*args) @docker_connection = ::Docker::Connection.new(config[:socket], :read_timeout => config[:read_timeout]) if Kitchen.logger.debug? ::Docker.logger = Kitchen.logger end end |
Instance Method Details
#create(state) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/kitchen/driver/docker.rb', line 78 def create(state) state[:image_id] = create_image(state) unless state[:image_id] state[:container_id] = create_container(state) unless state[:container_id] state[:hostname] = container_ssh_host state[:port] = container_ssh_port(state) wait_for_sshd(state[:hostname], nil, :port => state[:port]) end |
#default_container_name ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/kitchen/driver/docker.rb', line 59 def default_container_name platform = instance.platform.name suite = instance.suite.name cookbook = instance.provisioner.instance_variable_get("@config")[:kitchen_root].split('/').last hostname = Socket.gethostname.split('.').first ts = Time.now().strftime("%s") [platform,cookbook,suite,hostname,ts].join('..') end |
#default_image ⇒ Object
68 69 70 71 |
# File 'lib/kitchen/driver/docker.rb', line 68 def default_image platform, release = instance.platform.name.split('-') release ? [platform, release].join(':') : platform end |
#default_platform ⇒ Object
73 74 75 76 |
# File 'lib/kitchen/driver/docker.rb', line 73 def default_platform platform, release = instance.platform.name.split('-') release ? platform : 'ubuntu' end |
#destroy(state) ⇒ Object
86 87 88 |
# File 'lib/kitchen/driver/docker.rb', line 86 def destroy(state) destroy_container(state) if state[:container_id] end |