provisioners/docker: only allow 'args' special

This commit is contained in:
Mitchell Hashimoto 2013-12-03 14:35:56 -08:00
parent 33d3c28086
commit 8d6cac959f
1 changed files with 1 additions and 29 deletions

View File

@ -65,41 +65,13 @@ module VagrantPlugins
end end
def create_container(config) def create_container(config)
# DISCUSS: Does this really belong here?
ensure_bind_mounts_exist(config)
args = "-cidfile=#{config[:cidfile]} -d " args = "-cidfile=#{config[:cidfile]} -d "
args << prepare_run_arguments(config) args << config[:args] if config[:args]
@machine.communicate.sudo %[ @machine.communicate.sudo %[
rm -f #{config[:cidfile]} rm -f #{config[:cidfile]}
docker run #{args} #{config[:image]} #{config[:cmd]} docker run #{args} #{config[:image]} #{config[:cmd]}
] ]
end end
private
def ensure_bind_mounts_exist(config)
Array(config[:volumes]).each do |volume|
if volume =~ /(.+):.+/
guest_vm_path = $1
@machine.communicate.sudo "mkdir -p #{guest_vm_path}"
end
end
end
def prepare_run_arguments(config)
args = []
args << "-dns=#{config[:dns]}" if config[:dns]
args << "-name=#{config[:name]}" if config[:name]
args << "#{config[:additional_run_args]}" if config[:additional_run_args]
args += Array(config[:volumes]).map { |volume| "-v #{volume}" }
args += Array(config[:ports]).map { |port| "-p #{port}" }
args += Array(config[:links]).map { |link| "-link #{link}" }
args.compact.flatten.join ' '
end
end end
end end
end end