From 857b989c4701abcdb79edbc428634e0001a44e95 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 4 Mar 2014 07:31:13 -0800 Subject: [PATCH] provisioners/docker: setting to not auto assign name --- plugins/provisioners/docker/config.rb | 1 + .../plugins/provisioners/docker/config_test.rb | 17 +++++++++++++++++ .../docs/source/v2/provisioning/docker.html.md | 3 +++ 3 files changed, 21 insertions(+) diff --git a/plugins/provisioners/docker/config.rb b/plugins/provisioners/docker/config.rb index 9526bd4ce..e38d607b4 100644 --- a/plugins/provisioners/docker/config.rb +++ b/plugins/provisioners/docker/config.rb @@ -70,6 +70,7 @@ module VagrantPlugins @__containers.each do |name, params| params[:image] ||= name + params[:auto_assign_name] = true if !params.has_key?(:auto_assign_name) params[:daemonize] = true if !params.has_key?(:daemonize) end end diff --git a/test/unit/plugins/provisioners/docker/config_test.rb b/test/unit/plugins/provisioners/docker/config_test.rb index 82417573c..282e7af40 100644 --- a/test/unit/plugins/provisioners/docker/config_test.rb +++ b/test/unit/plugins/provisioners/docker/config_test.rb @@ -56,10 +56,12 @@ describe VagrantPlugins::Docker::Config do cs = result.containers expect(cs.length).to eq(2) expect(cs["foo"]).to eq({ + auto_assign_name: true, image: "foo", daemonize: false, }) expect(cs["bar"]).to eq({ + auto_assign_name: true, image: "bar", daemonize: true, }) @@ -97,6 +99,20 @@ describe VagrantPlugins::Docker::Config do subject.finalize! expect(subject.containers).to eql({ "foo" => { + auto_assign_name: true, + daemonize: true, + image: "foo", + } + }) + end + + it "can not auto assign name" do + subject.run("foo", auto_assign_name: false) + + subject.finalize! + expect(subject.containers).to eql({ + "foo" => { + auto_assign_name: false, daemonize: true, image: "foo", } @@ -109,6 +125,7 @@ describe VagrantPlugins::Docker::Config do subject.finalize! expect(subject.containers).to eql({ "foo" => { + auto_assign_name: true, daemonize: false, image: "foo", } diff --git a/website/docs/source/v2/provisioning/docker.html.md b/website/docs/source/v2/provisioning/docker.html.md index 203558a91..064af6f81 100644 --- a/website/docs/source/v2/provisioning/docker.html.md +++ b/website/docs/source/v2/provisioning/docker.html.md @@ -132,6 +132,9 @@ to the name, the `run` method accepts a set of options, all optional: * `args` (string) - Extra arguments for [`docker run`](http://docs.docker.io/en/latest/commandline/cli/#run) on the command line. These are raw arguments that are passed directly to Docker. +* `auto_assign_name` (boolean) - If true, the `-name` of the container will + be set to the first argument of the run. By default this is true. + * `daemonize` (boolean) - If true, the "-d" flag is given to `docker run` to daemonize the containers. By default this is true.