8 ms·
How does Vagrant work with Docker? Why do you need Vagrant if you're using Docker?
by Kiro 9y ago
How does Vagrant work with Docker? Why do you need Vagrant if you're using Docker?
- choward 9y agoVagrant abstracts virtual machines. If you want to simulate multiple machines on the same computer you need VMs. You can have multiple docker containers running in those VMs that communicate across VMs. You can then deploy to real hardware having tested the communication across machines.
- justinhj 9y agoYou can also run multiple docker-machine instances which can run on say VirtualBox. This is a how we have developers learn about and test Docker Swarm on a single machine. I've really run out of use cases for Vagrant at this point.
- Pirate-of-SV 9y agoDocker performs much better on a VirtualBox VM than the VM used by Docker for Mac
- n42 9y agoThis is, in my experience, not true. Anecdotally, xhyve has performed much better for Docker; especially when choosing the appropriate method for volume mount consistency[1], which has solved most FS performance issues I have run into. [1] https://docs.docker.com/docker-for-mac/osxfs-caching/ https://docs.docker.com/docker-for-mac/osxfs-caching/
- wuunderbar 9y agoVagrant lets you provision in a codified manner full-fledge VMs. This code can be pulled down by your developers to deploy a development environment on their machines. Inside of this you can choose to run containers of your apps with proper tooling built around it.
- mateuszf 9y agoCan't you do the same thing with docker, docker compose?
- moondev 9y agoNo, because containers are processes not vms.
- derimagia 9y agoYou can get close but as someone else said, they are mean't to be processes. You can get more control with Vagrant for a lot of things and have actual VMs.
- bboreham 9y agoThe equivalent tool is docker-machine, not docker compose. Though they de-emphasised that tool in favour of Docker for Mac and Docker for Windows which interact directly with the platform hypervisor to create a Linux VM.
- giobox 9y agoIf you've recently migrated your stack to a fully docker containerised setup, docker-compose can be a great replacement for an old vagrant provisioning setup, as the startup time will usually be a fraction of that needed by running vagrant up. It won't make sense for every project, but it's definitely a viable option for some.
- lunchables 9y agoThis is the best definition I saw posted. The best sales pitch I've seen for Vagrant is that it lets you create a config ("Vagrantfile") from which you can build a virtual machine. Now you, or someone else, can take that vagrant config and recreate the same vm (on multiple platforms btw - virtualbox, kvm, etc) for testing and development.
- jitl 9y agoVagrant is useful if you want to simulate a whole box, or a cluster of boxes - for example, you can spin up a cluster of 3 VMs to run Mesosphere DC/OS [0]. If you build and deploy just containers, and don't have any full VMs in your stack, then you might not need Vagrant. Vagrant also claims to provide a "good workflow for writing Dockerfiles"; it can provide a nicer user abstraction over `docker [many, many args]` for running your biz [1]. [0]: https://github.com/dcos/dcos-vagrant#dcos-vagrant https://github.com/dcos/dcos-vagrant#dcos-vagrant [1]: https://www.vagrantup.com/docs/docker/basics.html https://www.vagrantup.com/docs/docker/basics.html
- valfadeev 9y agoThis is exactly where I began getting the most out of Vagrant, that is, simulating a distributed cluster locally. It gets me as close as possible to how it would work on the provider infrastructure, e.g. AWS. In particular, spinning up an automated Consul cluster and then using it get a group of RabbitMQ nodes to converge[0]. The same is certainly achievable through container orchestration, but that adds more layers of abstraction, especially on the networking side. [0]: https://github.com/ValFadeev/consul-demo https://github.com/ValFadeev/consul-demo
- camus2 9y agoRunning Linux/debian/freebsd on Windows/Mac, Simulating actual networks on a single computer ... You can then run Docker inside a Vagrant VM.