Skip to content

Commit

Permalink
Allow Mac/Windows users to use Docker native
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed May 27, 2016
1 parent db1f98f commit 8c11b53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion plugins/providers/docker/config.rb
@@ -1,5 +1,7 @@
require "pathname"

require_relative "../../../lib/vagrant/util/platform"

module VagrantPlugins
module DockerProvider
class Config < Vagrant.plugin("2", :config)
Expand Down Expand Up @@ -202,7 +204,6 @@ def finalize!
@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
Expand All @@ -223,6 +224,13 @@ def finalize!
@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

Expand Down
1 change: 1 addition & 0 deletions test/unit/plugins/providers/docker/config_test.rb
Expand Up @@ -60,6 +60,7 @@ def valid_defaults
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
Expand Down
6 changes: 5 additions & 1 deletion website/source/docs/docker/configuration.html.md
Expand Up @@ -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.
Expand Down

1 comment on commit 8c11b53

@till
Copy link
Contributor

@till till commented on 8c11b53 May 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.