Hacker News new | ask | show | jobs
by mickeyp 3162 days ago
Yes, with the caveat that if you already use a hypervisor for your main dev environment then running another inside it with Vagrant's default VBox setup is likely to either be very slow or not work at all.

Docker will also layer and cache each command greatly speeding up the "build&test" cycle of writing and running Docker containers. With Vagrant you're re-running everything every time.

Furthermore, you can actually use Docker with Vagrant also nowadays.

1 comments

This sounds like a rare scenario, much more common these days I believe would be a non-Linux host, with a Linux "guest" server environment.

If you want to use Docker, you're then automatically using a hypervisor anyway.

> With Vagrant you're re-running everything every time.

Are you talking about the time to provision a non-created environment?

On a clean install, sure, that might take a while if your base-box doesn't have the dependencies you require - but most developers wouldn't often need to re-build their Vagrant environment for a project from scratch (i.e. vagrant destroy is not likely to be a common task). And that whole situation is moot if you use or build a more appropriate base box.

Is it that uncommon? Mac users using a hypervisor? Windows using running Linux in a Virtualbox? That's pretty common in corporate environments...

I am talking about rebuilding the Vagrant image every time you change it - as you are wont to do during the initial step of creating it. Sure, once it's written (by someone who has to spend a fair amount of elapsed time doing trial-and-error tweaks) then you don't have to re-cycle the image. On the other hand, that too can result in people using stale images over time as the configuration drifts.

> Mac users using a hypervisor? Windows using running Linux in a Virtualbox?

Vagrant works natively on Macs and Windows, unlike Docker. There is zero reason to run it inside an already virtualised environment on those machines.

> I am talking about rebuilding the Vagrant image every time you change it

You know you don't need to destroy the vagrant environment to re-run the provisioning scripts, if something changes.. right?

> Sure, once it's written (by someone who has to spend a fair amount of elapsed time doing trial-and-error tweaks)

With the minor exception of a few Vagrant specific optimisations (a `vagrant` user with the predefined SSH key & passwordless sudo, for example) during base-box building, literally nothing in a Vagrant provisioning environment needs to be specific to Vagrant.

Also - if you're building base-boxes, it's probably worthwhile forking an existing project that targets your Distro/OS of choice and customising from there.

> On the other hand, that too can result in people using stale images over time as the configuration drifts.

Why? If it's a small change, just set the provisioner to `run: "always"` and it will run on every up. Assuming the changes (i.e. new/updated deps, or config files being copied) are small, it'll be almost instantaneous.

From everything you've said, I'm very curious how you use Vagrant (if at all). It isn't intended to be used like Docker, where you package up an entire image completely ready to use with 0 cycles needed to configure anything, and an update means a new image.