Skip to content

Commit

Permalink
provisioners/docker: setting to not auto assign name
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Mar 4, 2014
1 parent 5ce0918 commit 857b989
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/provisioners/docker/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def finalize!

@__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
Expand Down
17 changes: 17 additions & 0 deletions test/unit/plugins/provisioners/docker/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@
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,
})
Expand Down Expand Up @@ -97,6 +99,20 @@
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",
}
Expand All @@ -109,6 +125,7 @@
subject.finalize!
expect(subject.containers).to eql({
"foo" => {
auto_assign_name: true,
daemonize: false,
image: "foo",
}
Expand Down
3 changes: 3 additions & 0 deletions website/docs/source/v2/provisioning/docker.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 857b989

Please sign in to comment.