Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancements - native docker provider for mac users #7240

Closed
ozbillwang opened this issue Apr 18, 2016 · 17 comments
Closed

enhancements - native docker provider for mac users #7240

ozbillwang opened this issue Apr 18, 2016 · 17 comments

Comments

@ozbillwang
Copy link

ozbillwang commented Apr 18, 2016

Vagrant version

Run vagrant -v to show the version. If you are not running the latest version
of Vagrant, please upgrade before submitting an issue.

latest

Host operating system

This is the operating system that you run locally.

mac osx 10.11.3

Guest operating system

This is the operating system you run in the virtual machine.

need support xhyve ( a lightweight OS X virtualization solution)
https://github.com/mist64/xhyve

Vagrantfile

Vagrant.configure(2) do |config|
  config.vm.provider "docker" do |d|
    d.image = "centos"
  end
end

Debug output

$ vagrant up --provider=docker
Bringing machine 'default' up with 'docker' provider...
==> default: Docker host is required. One will be created if necessary...
    default: Vagrant will now create or start a local VM to act as the Docker
    default: host. You'll see the output of the `vagrant up` for this VM below.
    default:
    default: Checking if box 'hashicorp/boot2docker' is up to date...

Expected behavior

What should have happened?

native docker use Xhyve, no need boot2docker any more.

Actual behavior

What actually happened?

still go with boot2docker

Steps to reproduce

  1. install native docker for mac
  2. vagrant up --provider=docker
  3. a new VM started in Virtualbox.

References

Are there any other GitHub issues (open or closed) that should be linked here?
For example:

@ozbillwang
Copy link
Author

ozbillwang commented Apr 18, 2016

If this is possible, no vagrant boxes required any more.

  • install native docker for mac or windows.
  • run vagrant up with docker provider in docker containers and it will be faster than vagrant box.

"Faster and more reliable: no more VirtualBox! The Docker engine is running in an Alpine Linux distribution on top of an xhyve Virtual Machine on Mac OS X or on a Hyper-V VM on Windows, and that VM is managed by the Docker application. You don’t need docker-machine to run Docker for Mac and Windows."

@sethvargo
Copy link
Contributor

Hi there,

Thank you for opening an issue. This is closely related to #6187. In general, we prefer to see new technologies developed as plugins first, then, as they gain maturity and adoption, we can address moving them into Vagrant core. Thanks!

@lucyllewy
Copy link

I'd just like drop a friendly note to document that this is not about supporting xhyve per #6187, but is actually about supporting docker using the now-native implementations on windows and os x. These native implementations do not use boot2docker anymore and instead handle the starting and management of a docker environment directly, which vagrant should interact with via the standard docker mechanisms.

specifically vagrant should NOT try to start any VMs when docker is requested under these systems.
Vagrant should instead just use docker directly similarly to how it behaves on a linux system.

@ozbillwang
Copy link
Author

ozbillwang commented Jun 2, 2016

thanks to add comments on this idea, @diddledan

We need develop a new vagrant driver to support xhyve first, without this plug-in, we can't go further.

@sethvargo
Copy link
Contributor

Hi @diddledan

The next version of Vagrant allows the user to opt out of the host-VM using an envvar; this will be a good gap that will allow users to use the native tools while they are still in beta.

@binary132
Copy link

@sethvargo does this feature exist yet, e.g. in a beta?

@sethvargo
Copy link
Contributor

@ozbillwang
Copy link
Author

ozbillwang commented Jul 28, 2016

Thanks, @sethvargo

Any sample Vagrantfile for sharing to set force_host_vm to true. I'd like to work it with native docker for mac

@conatus
Copy link

conatus commented Sep 20, 2016

Plus one for this guys. Native support for Docker for Mac (and Windows) is now out a beta.

@sethvargo
Copy link
Contributor

It already exists and was in 1.8.4 if I recall correctly.

@ozbillwang
Copy link
Author

ozbillwang commented Sep 21, 2016

@sethvargo

Still doesn't work with native docker for mac.

Used the sample and copy from https://www.vagrantup.com/docs/docker/commands.html

$ vagrant --version
Vagrant 1.8.4

$ cat Vagrantfile
Vagrant.configure(2) do |config|
  config.vm.provider "docker" do |d|
    d.image = "consul"
  end
end

$ vagrant up --provider=docker
Bringing machine 'default' up with 'docker' provider...
==> default: Docker host is required. One will be created if necessary...
    default: Docker host VM is already ready.
==> default: Syncing folders to the host VM...
    default: Installing rsync to the VM...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

rsync --help

Stdout from the command:

Stderr from the command:

sh: rsync: not found

$ docker version
Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 17:32:24 2016
 OS/Arch:      darwin/amd64
 Experimental: true

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 17:32:24 2016
 OS/Arch:      linux/amd64
 Experimental: true

@ozbillwang
Copy link
Author

Did with Vagrant 1.8.5, same error.

@mvermaes
Copy link

You need to set force_host_vm to false, as Seth mentioned. Try:

Vagrant.configure(2) do |config|
  config.vm.provider "docker" do |d|
    d.image = "consul"
    d.force_host_vm = false
  end
end

@ozbillwang
Copy link
Author

@mvermaes

Thanks, I can start with docker provider with native docker for mac.

I am fine to close this ticket now.

Command: ["docker", "run", "--name", "tmp_default_1474432125", "-d", "-v", "/private/tmp:/vagrant", "consul", {:notify=>[:stdout, :stderr]}]

@glensc
Copy link
Contributor

glensc commented Nov 30, 2016

#7240 (comment)

i think d.force_host_vm is unfortunately bad name. to tell vagrant not to use own boot2docker, i have to tell:

d.force_host_vm = false

which may lead to believe vagrant by default forces. it's a bit illogical to say "force=false", the better option would be to make boolean variable:

# use xhyve
d.use_host_vm = true
# use boot2docker
d.use_host_vm = false

ps: d.force_host_vm = false boots here with vagrant 1.9.0, but it's unable to ssh in because it uses container internal ip, not the mapped one:

# docker ps
ed239a2b4c94        vagrant   "/usr/local/sbin/sshd"   11 minutes ago      Up 11 minutes       127.0.0.1:2200->22/tcp   dind_default_1480510372

but vagrant connects to:

 INFO ssh: Invoking SSH: ssh ["vagrant@172.17.0.2", "-p", "22", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "LogLevel=FATAL", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "/Users/glen/.vagrant.d/insecure_private_key", "-o", "ForwardAgent=yes"]

it should connect to 127.0.0.1:2200

is there known workaround to tell the hostname:port to vagrant?

@glensc
Copy link
Contributor

glensc commented Nov 30, 2016

ok, found answer from here:

    config.ssh.host = 'localhost'
    config.ssh.guest_port = '2200'

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants