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



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

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

#destroy(state) ⇒ Object



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

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