lib/vocker/docker_client.rb in vocker-0.1.0 vs lib/vocker/docker_client.rb in vocker-0.2.0

- old
+ new

@@ -22,17 +22,23 @@ def run(containers) containers.each do |name, config| cids_dir = "/var/lib/vocker/cids" config[:cidfile] ||= "#{cids_dir}/#{Digest::SHA1.hexdigest name}" - id = "$(cat #{config[:cidfile]})" - @machine.communicate.sudo("mkdir -p #{cids_dir}") - if container_exist?(id) - start_container(id) - else - create_container(config) - end + run_container(config) + end + end + + def run_container(config) + raise "Container's cidfile was not provided!" unless config[:cidfile] + + id = "$(cat #{config[:cidfile]})" + + if container_exist?(id) + start_container(id) + else + create_container(config) end end def container_exist?(id) @machine.communicate.test("sudo docker ps -a -q | grep -q #{id}")