provisioners/docker: config to disablize -d flag

This commit is contained in:
Mitchell Hashimoto 2014-02-03 16:14:59 +01:00
parent b89a47c955
commit 1d69e95c1c
5 changed files with 33 additions and 1 deletions

View File

@ -37,6 +37,7 @@ IMPROVEMENTS:
- provisioners/chef-solo: New config `synced_folder_type` replaces the
`nfs` option. This can be used to set the synced folders the provisioner
needs to any type. [GH-2709]
- provisioners/docker: Can start a container without daemonization.
- provisioners/puppet: New config `synced_folder_type` replaces the
`nfs` option. This can be used to set the synced folders the provisioner
needs to any type. [GH-2709]

View File

@ -75,7 +75,8 @@ module VagrantPlugins
end
def create_container(config)
args = "-cidfile=#{config[:cidfile]} -d "
args = "-cidfile=#{config[:cidfile]} "
args << "-d " if config[:daemonize]
args << config[:args] if config[:args]
@machine.communicate.sudo %[
rm -f #{config[:cidfile]}

View File

@ -32,6 +32,7 @@ module VagrantPlugins
def run(name, **options)
params = options.dup
params[:image] ||= name
params[:daemonize] = true if !params.has_key?(:daemonize)
# TODO: Validate provided parameters before assignment
@containers[name.to_s] = params

View File

@ -40,6 +40,32 @@ describe VagrantPlugins::Docker::Config do
end
end
describe "#run" do
it "runs the given image" do
subject.run("foo")
subject.finalize!
expect(subject.containers).to eql({
"foo" => {
daemonize: true,
image: "foo",
}
})
end
it "can not daemonize" do
subject.run("foo", daemonize: false)
subject.finalize!
expect(subject.containers).to eql({
"foo" => {
daemonize: false,
image: "foo",
}
})
end
end
describe "#version" do
it "defaults to latest" do
subject.finalize!

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)
on the command line. These are raw arguments that are passed directly to Docker.
* `daemonize` (boolean) - If true, the "-d" flag is given to `docker run` to
daemonize the containers. By default this is true.
For example, here is how you would configure Docker to run a container
with the Vagrant shared directory mounted inside of it: