diff --git a/plugins/providers/docker/driver.rb b/plugins/providers/docker/driver.rb index 35e8b73b8..37d109d9b 100644 --- a/plugins/providers/docker/driver.rb +++ b/plugins/providers/docker/driver.rb @@ -29,7 +29,7 @@ module VagrantPlugins def create(params, **opts, &block) image = params.fetch(:image) - links = params.fetch(:links) + links = Array(params.fetch(:links)) ports = Array(params[:ports]) volumes = Array(params[:volumes]) name = params.fetch(:name) @@ -41,7 +41,7 @@ module VagrantPlugins run_cmd << "-d" if params[:detach] run_cmd += env.map { |k,v| ['-e', "#{k}=#{v}"] } run_cmd += expose.map { |p| ['--expose', "#{p}"] } - run_cmd += links.map { |k, v| ['--link', "#{k}:#{v}"] } + run_cmd += links.map { |l| ['--link', "#{l}"] } run_cmd += ports.map { |p| ['-p', p.to_s] } run_cmd += volumes.map { |v| ['-v', v.to_s] } run_cmd += %W(--privileged) if params[:privileged] diff --git a/test/unit/plugins/providers/docker/config_spec.rb b/test/unit/plugins/providers/docker/config_test.rb similarity index 100% rename from test/unit/plugins/providers/docker/config_spec.rb rename to test/unit/plugins/providers/docker/config_test.rb diff --git a/test/unit/plugins/providers/docker/driver_spec.rb b/test/unit/plugins/providers/docker/driver_test.rb similarity index 91% rename from test/unit/plugins/providers/docker/driver_spec.rb rename to test/unit/plugins/providers/docker/driver_test.rb index c41bb3924..17ee06609 100644 --- a/test/unit/plugins/providers/docker/driver_spec.rb +++ b/test/unit/plugins/providers/docker/driver_test.rb @@ -16,6 +16,9 @@ describe VagrantPlugins::DockerProvider::Driver do cmd: ['play', 'voodoo-chile'], ports: '8080:80', volumes: '/host/path:guest/path', + detach: true, + links: 'janis:joplin', + env: {key: 'value'}, name: cid, hostname: 'jimi-hendrix', privileged: true @@ -28,7 +31,7 @@ describe VagrantPlugins::DockerProvider::Driver do end it 'sets container name' do - expect(cmd_executed).to match(/-name #{Regexp.escape params[:name]}/) + expect(cmd_executed).to match(/--name #{Regexp.escape params[:name]}/) end it 'forwards ports' do @@ -39,8 +42,16 @@ describe VagrantPlugins::DockerProvider::Driver do expect(cmd_executed).to match(/-v #{params[:volumes]} .+ #{Regexp.escape params[:image]}/) end + it 'links containers' do + expect(cmd_executed).to match(/--link #{params[:links]} .+ #{Regexp.escape params[:image]}/) + end + + it 'sets environmental variables' do + expect(cmd_executed).to match(/-e key=value .+ #{Regexp.escape params[:image]}/) + end + it 'is able to run a privileged container' do - expect(cmd_executed).to match(/-privileged .+ #{Regexp.escape params[:image]}/) + expect(cmd_executed).to match(/--privileged .+ #{Regexp.escape params[:image]}/) end it 'sets the hostname if specified' do diff --git a/test/unit/plugins/providers/docker/synced_folder_spec.rb b/test/unit/plugins/providers/docker/synced_folder_test.rb similarity index 100% rename from test/unit/plugins/providers/docker/synced_folder_spec.rb rename to test/unit/plugins/providers/docker/synced_folder_test.rb