Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Vagrant and Docker together, by example

Tags:

docker

vagrant

So this weekend I installed both Vagrant and Docker on my laptop and played around with them a little bit. I totally understand that they are different beasts with different intentions in mind. But I can't help to think: how could they be used to complement each other?

If you Google "Docker vs Vagrant" you'll get an ocean of blogs and articles stating how these two technologies are different. But I have yet to come across a single concrete article demonstrating how these two technologies can be used with each other. I assume there has to be specific scenarios where one would use both, otherwise there would be no reason to have the Vagrant-Docker provisioner.

So I ask: Can someone please provide me with a concrete scenario(s) in which a dev would use both Docker and Vagrant? Perhaps using Vagrant to manage a local VM and then perhaps Docker for "converting" that configured (with deployed application in tow) VM to a container, or something thereabouts?

I'm looking for specific, fairly detailed scenarios here! Thanks in advance!

like image 450
smeeb Avatar asked Aug 16 '15 16:08

smeeb


2 Answers

This question is very broad but for dev environments you can use as your creativity spans.

So one scenario that I can think of is that you are running say Ubuntu in your production environment with Docker containers. Say your developers have Mac OS X machines running VirtualBox, but you want want their environment to be as close as possible to the production environment. So use Vagrant with Ubuntu VM and in that VM run Docker containers.

The same can be said about Windows machines, what if your production environment is all Ubuntu with Docker. You can emulated with Vagrant and VirtualBox too.

like image 110
Rico Avatar answered Nov 12 '22 15:11

Rico


Often considered two alternative tools, Docker and Vagrant can be used together to build isolated and repeatable development environments. We will prove it setting up a Docker container for development of a Java application and taking advantage of Vagrant powerful features to solve some real life practical issues.

https://blog.zenika.com/2014/10/07/setting-up-a-development-environment-using-docker-and-vagrant/

like image 34
user9205982 Avatar answered Nov 12 '22 15:11

user9205982