provisioners/docker: setting to not auto assign name

This commit is contained in:
Mitchell Hashimoto 2014-03-04 07:31:13 -08:00
parent 5ce0918190
commit 857b989c47
3 changed files with 21 additions and 0 deletions

View File

@ -70,6 +70,7 @@ module VagrantPlugins
@__containers.each do |name, params| @__containers.each do |name, params|
params[:image] ||= name params[:image] ||= name
params[:auto_assign_name] = true if !params.has_key?(:auto_assign_name)
params[:daemonize] = true if !params.has_key?(:daemonize) params[:daemonize] = true if !params.has_key?(:daemonize)
end end
end end

View File

@ -56,10 +56,12 @@ describe VagrantPlugins::Docker::Config do
cs = result.containers cs = result.containers
expect(cs.length).to eq(2) expect(cs.length).to eq(2)
expect(cs["foo"]).to eq({ expect(cs["foo"]).to eq({
auto_assign_name: true,
image: "foo", image: "foo",
daemonize: false, daemonize: false,
}) })
expect(cs["bar"]).to eq({ expect(cs["bar"]).to eq({
auto_assign_name: true,
image: "bar", image: "bar",
daemonize: true, daemonize: true,
}) })
@ -97,6 +99,20 @@ describe VagrantPlugins::Docker::Config do
subject.finalize! subject.finalize!
expect(subject.containers).to eql({ expect(subject.containers).to eql({
"foo" => { "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, daemonize: true,
image: "foo", image: "foo",
} }
@ -109,6 +125,7 @@ describe VagrantPlugins::Docker::Config do
subject.finalize! subject.finalize!
expect(subject.containers).to eql({ expect(subject.containers).to eql({
"foo" => { "foo" => {
auto_assign_name: true,
daemonize: false, daemonize: false,
image: "foo", image: "foo",
} }

View File

@ -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) * `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. 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` (boolean) - If true, the "-d" flag is given to `docker run` to
daemonize the containers. By default this is true. daemonize the containers. By default this is true.