17

Can anybody explain to me the difference?

Provisioner - is something doing provision - in docker installing, running, pulling containers.

Provider - is something that runs the VM. I.e. VBox runs the ubuntu OS image.

How can be Docker a provider? It runs directly some docker image? If I'm on windows there must some hidden usage of boot2docker right? When will I use each one?

Zveratko
  • 2,663
  • 6
  • 35
  • 64

1 Answers1

10

Docker provisioner help to prepare environment: build and pull images, run containers if you need multiple containers running for your vagrant machine. Docker provider is running vagrant machine in docker container (instead of VM/cloud as other providers do).

On Linux vagrant is using docker from the host OS. On Windows and MacOS X boot2docker is used for both docker provisioner and provider. By default all vagrant docker machines are using the same boot2docker instance - but you could configure which VM to use (It does not need to be boot2docker - any Linux with docker is ok).

ISanych
  • 21,590
  • 4
  • 32
  • 52
  • Why would I like to run vagrant in docker machine? Vagrant is helpful to run docker anywhere but vice versa? This use case for Windows means running boot2docker that runs vagrant container, which can run docker again. Vagrant in docker container, why? "On linux vagrant is using docker from host OS", so I have vagrant image and it somehow is using docker installed on host? Can you please clarify a little bit more? – Zveratko May 23 '15 at 15:32
  • 1
    @Zveratko, it could be different reasons: on linux docker is faster and more resource efficient than any vm, it may be some docker container which you want to use. But I personally prefer to use docker directly - I completely migrated from vagrant to docker, but it is matter of preferences and use cases. – ISanych May 23 '15 at 17:48
  • Now I'm trying to understand [this](http://blog.scottlowe.org/2015/02/10/using-docker-with-vagrant/). They are using Docker as Vagrant provider and then they are provisioning Vagrant with Docker. For me it seams like somebody is catching his own tail. The same [here](http://itsmyviewofthings.blogspot.cz/2014/06/docker-dev-in-box-environment-setup.html) they have one vagrant file which on startup will run second vagrant file to define the machine to run docker(not boot2docker), then they run docker file. Why are they using config.vm.define? – Zveratko Jun 03 '15 at 12:17
  • 1
    You need vm if you want to use docker on MacOS/Windows, and they want to use own vm instead of boot2docker. Quote from the first link: "But what if you don’t want to use boot2docker? What if you’d rather use Ubuntu or CentOS, so that what you do in Vagrant more closely matches what you might do in the data center?". It is optional and in most cases default is ok. From my point of view only people who are using vagrant for many other purposes will be using vagrant + docker. If you using vagrant only with docker I don't see a point here, better to use docker directly. – ISanych Jun 03 '15 at 14:25
  • What confuses me the most is why I need two files. I thought one Vagrant file equals one VM. I have found new [link](http://www.maori.geek.nz/post/vagrant_with_docker_how_to_set_up_postgres_elasticsearch_and_redis_on_mac_os_x) with similar structure, which states following(see next comment). There is again config.vm.define used, this defines vagrant machine, but it is provisioned by docker so, I hope it means that docker conteiner. I'm still confused. I need to stop thinking for a while about docker beeing both provisioner and provider, it makes it complicated. – Zveratko Jun 04 '15 at 05:23
  • `When describing Docker containers, Vagrant makes each container look like it is its own virtual machine. But this is a lie, as each Docker container is actually running in a "proxy" virtual machine. Therefore, two Vagrant files are required, one to define the proxy virtual machine (the provisioner) and one to define the the Docker containers (the providers).` – Zveratko Jun 04 '15 at 05:24
  • 1
    It is a rare case when you need 2 Vagrant files - you could use default approach when vagrant will use boot2docker when it necessary and it will be transparent to you - yes, all docker containers will be using one machine (physical or virtual, depends on your os) but it should not be an issue and allows to use docker strengths - faster start time and better resource utilisation. – ISanych Jun 04 '15 at 11:12