Allow Mac/Windows users to use Docker native

This commit is contained in:
Seth Vargo 2016-05-27 17:36:07 -04:00
parent db1f98ffd6
commit 8c11b537ba
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
3 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,7 @@
require "pathname"
require_relative "../../../lib/vagrant/util/platform"
module VagrantPlugins
module DockerProvider
class Config < Vagrant.plugin("2", :config)
@ -202,7 +204,6 @@ module VagrantPlugins
@create_args = [] if @create_args == UNSET_VALUE
@dockerfile = nil if @dockerfile == UNSET_VALUE
@env ||= {}
@force_host_vm = false if @force_host_vm == UNSET_VALUE
@has_ssh = false if @has_ssh == UNSET_VALUE
@image = nil if @image == UNSET_VALUE
@name = nil if @name == UNSET_VALUE
@ -223,6 +224,13 @@ module VagrantPlugins
@host_vm_build_dir_options = nil
end
# On non-linux platforms (where there is no native docker), force the
# host VM. Other users can optionally disable this by setting the
# value explicitly to false in their Vagrantfile.
if @force_host_vm == UNSET_VALUE
@force_host_vm = !Vagrant::Util::Platform.linux?
end
# The machine name must be a symbol
@vagrant_machine = @vagrant_machine.to_sym if @vagrant_machine

View File

@ -60,6 +60,7 @@ describe VagrantPlugins::DockerProvider::Config do
before do
# By default lets be Linux for validations
Vagrant::Util::Platform.stub(linux: true)
Vagrant::Util::Platform.stub(linux?: true)
end
it "should be invalid if both build dir and image are set" do

View File

@ -50,7 +50,11 @@ General settings:
* `force_host_vm` (boolean) - If true, then a host VM will be spun up
even if the computer running Vagrant supports Linux containers. This
is useful to enforce a consistent environment to run Docker.
is useful to enforce a consistent environment to run Docker. This value
defaults to "true" on Mac and Windows hosts and defaults to "false" on
Linux hosts. Mac/Windows users who choose to use a different Docker
provider or opt-in to the native Docker builds can explicitly set this
value to false to disable the behavior.
* `has_ssh` (boolean) - If true, then Vagrant will support SSH with
the container. This allows `vagrant ssh` to work, provisioners, etc.