From faba9bdae9ab5ea50bd87a59060b8f3817eefdf2 Mon Sep 17 00:00:00 2001 From: Gosha Arinich Date: Thu, 8 May 2014 21:10:37 +0300 Subject: [PATCH 1/2] Revert "providers/docker: Container links are an array, not a hash" This reverts commit b68cb6d7b408a494dccb96383b20387de7db0339. --- plugins/providers/docker/driver.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/providers/docker/driver.rb b/plugins/providers/docker/driver.rb index 546b06dfd..987437c1b 100644 --- a/plugins/providers/docker/driver.rb +++ b/plugins/providers/docker/driver.rb @@ -31,7 +31,7 @@ module VagrantPlugins def create(params, **opts, &block) image = params.fetch(:image) - links = Array(params.fetch(:links)) + links = params.fetch(:links) ports = Array(params[:ports]) volumes = Array(params[:volumes]) name = params.fetch(:name) @@ -43,7 +43,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 { |l| ['--link', "#{l}"] } + run_cmd += links.map { |k, v| ['--link', "#{k}:#{v}"] } 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] From 7558524482f711c47861a7d99edade3fe65d7bbb Mon Sep 17 00:00:00 2001 From: Gosha Arinich Date: Thu, 8 May 2014 21:27:58 +0300 Subject: [PATCH 2/2] docker container links is actually a hash, fix tests --- test/unit/plugins/providers/docker/driver_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/plugins/providers/docker/driver_test.rb b/test/unit/plugins/providers/docker/driver_test.rb index 17ee06609..7486fc4d1 100644 --- a/test/unit/plugins/providers/docker/driver_test.rb +++ b/test/unit/plugins/providers/docker/driver_test.rb @@ -17,7 +17,7 @@ describe VagrantPlugins::DockerProvider::Driver do ports: '8080:80', volumes: '/host/path:guest/path', detach: true, - links: 'janis:joplin', + links: {janis: 'joplin'}, env: {key: 'value'}, name: cid, hostname: 'jimi-hendrix', @@ -43,7 +43,7 @@ describe VagrantPlugins::DockerProvider::Driver do end it 'links containers' do - expect(cmd_executed).to match(/--link #{params[:links]} .+ #{Regexp.escape params[:image]}/) + expect(cmd_executed).to match(/--link #{params[:links].to_a.flatten.join(':')} .+ #{Regexp.escape params[:image]}/) end it 'sets environmental variables' do