lib/kitchen/driver/docker.rb in kitchen-docker-0.1.2 vs lib/kitchen/driver/docker.rb in kitchen-docker-0.1.3

- old
+ new

@@ -26,11 +26,11 @@ # Docker driver for Kitchen. # # @author Sean Porter <portertech@gmail.com> class Docker < Kitchen::Driver::SSHBase - default_config :image, 'ubuntu' + default_config :image, 'base' default_config :platform, 'ubuntu' default_config :port, '22' default_config :username, 'kitchen' default_config :password, 'kitchen' default_config :require_chef_omnibus, true @@ -49,11 +49,11 @@ wait_for_sshd(state[:hostname]) ensure_fqdn(state) end def destroy(state) - kill_container(state) if state[:container_id] + rm_container(state) if state[:container_id] rm_image(state) if state[:image_id] end protected @@ -113,11 +113,15 @@ container_id end def run_container(state) image_id = state[:image_id] - cmd = "docker run -d #{image_id} /usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no" + cmd = "docker run -d" + Array(config[:forward]).each do |port| + cmd << " -p #{port}" + end + cmd << " #{image_id} /usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no" output = run_command(cmd) parse_container_id(output) end def parse_container_ip(output) @@ -139,12 +143,12 @@ def ensure_fqdn(state) ssh_args = build_ssh_args(state) ssh(ssh_args, 'echo "127.0.0.1 `hostname`" | sudo tee -a /etc/hosts') end - def kill_container(state) + def rm_container(state) container_id = state[:container_id] - run_command("docker kill #{container_id}") + run_command("docker rm #{container_id}") end def rm_image(state) image_id = state[:image_id] run_command("docker rmi #{image_id}")