Class: Kitchen::Driver::Dockerwin

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/driver/dockerwin.rb

Overview

DockerWindows - Windows Containers via Docker

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object


14
15
16
17
18
19
# File 'lib/kitchen/driver/dockerwin.rb', line 14

def create(state)
  run_command("docker pull #{instance.driver[:image]}") unless config[:skip_pull]
  mount_options = config[:mount_options] || "type=bind,source=\"#{ENV['TEMP']}\",target=\"#{ENV['TEMP']},readonly\""
  container_id = run_command("docker run -idt --mount #{mount_options} --name #{instance.name} #{instance.driver[:image]}").strip
  state[:container_id] = container_id
end

#destroy(state) ⇒ Object


21
22
23
24
25
26
27
28
29
# File 'lib/kitchen/driver/dockerwin.rb', line 21

def destroy(state)
  return if state[:container_id].nil?
  container_id = state[:container_id]
  info 'Killing container'
  run_command("docker kill #{container_id} > nul")
  info 'Removing container'
  run_command("docker rm #{container_id} > nul")
  state.delete(:container_id)
end

#finalize_config!(instance) ⇒ Object

Force the driver to use the Dockercli transport


32
33
34
35
36
# File 'lib/kitchen/driver/dockerwin.rb', line 32

def finalize_config!(instance)
  super.tap do
    instance.transport = Kitchen::Transport::Dockercli.new
  end
end