4

I have a set of microservices whose deployment I would like to automate and standardize using Docker. I have been reading about Vagrant and I have a couple of questions on using Vagrant for setting up the environment.

  1. I understand that Vagrant is used for setting up VM's and Docker for creating containers. What is the benefit of running a Docker container inside a VM? Doesn't it defeat the purpose of using Docker in the first place?

  2. How is the interaction between Vagrant and Docker happening? Does the VM that I create using Vagrant contain Docker running inside it?

joesan
  • 13,963
  • 27
  • 95
  • 232
  • link could be usefull http://stackoverflow.com/questions/16047306/how-is-docker-different-from-a-normal-virtual-machine – Ahmet Karakaya Apr 06 '16 at 11:03
  • That was an attempt to explain what Docker is. But it still does not answer my first question! – joesan Apr 06 '16 at 11:07
  • 1
    If you install Docker on Mac or Windows then this is realized by Boot2Docker. Boot2Docker is Docker inside a VM. Docker is currently a Linux-Only technology and technically Docker is a demon on a Linux system. So as a result, you need a Linux machine or VM with the Docker demon installed in order to be able to use Docker. You can automate VM provisioning and latest Docker version installation using Vagrant. Or you just create such a machine by using docker-machine. The advantage of Vagrant is that it supports more provisoners/virtualisations than docker-machine. – blacklabelops Apr 06 '16 at 11:33

1 Answers1

5

Answer for first question:

Vagrant is a way to quickly setup docker based container on your local machine. To run docker containers, you need linux kernel which you can provide either by running container on your physical machine. But having vagrant's provisioned vm and running containers will benefit in following way

  1. You can safely remove containers anytime.
  2. You can automate all docker commands via vagrant script.

Answer to second question:

Vagrant directly communicates with docker containers. Each docker container on VM gets their own IP and space. You may modify vagrant file for port forwarding per your machine need.

Hope it helps.

Azeem
  • 251
  • 5
  • 13
Sam
  • 859
  • 3
  • 12
  • 23
  • That's ok sparkr :) .. I just dont understand why people just act without any explanation.. – Sam May 06 '16 at 16:45
  • Yes, even I have been down voted for some questions that I ask. Down voting on a question is Ok as long as someone is asking for direct solutions, but with all of my questions I ask them with some code that either does not work or my understanding was wrong. Anyway, this is how the world it! I have given my up vote! – joesan May 07 '16 at 06:40