News for hackers. Stuff that matters.
Re:Things I Wish I'd Known Before Using Vagrant by bauerd on Friday October 27, 2017 @10:12AM (#15568443)
I was a long-time Vagrant user but recently switched almost completely to Docker (Compose). What features does Docker miss that make people keep using Vagrant?
Re:Things I Wish I'd Known Before Using Vagrant by RussianCow on Friday October 27, 2017 @11:39AM (#15569452)
To give a counter-point to all the praise here, Docker for Mac has been one of the most frustrating pieces of software I've had to use for work. It has improved significantly over the first time I used it (almost immediately after public beta), but I still occasionally run into various bugs, such as inotify events ceasing to work arbitrarily. Any kind of networking that makes your containers visible to the host/on the local network is also a PITA to set up through the VM that Docker for Mac uses. It's also supposed to abstract away the fact that it's actually running in a VM, but I have had to tweak the VM's CPU/memory settings multiple times, and it's not obvious when you have to do this. On top of that, last I checked, Docker for Windows is still missing some features like inotify events, and requires you to enable Hyper-V, which of course removes your ability to have other VMs running simultaneously.

The other side of it is that Vagrant is just easier. Docker requires everything to fit into a "one container per service, one process per container" model, which is a really good idea in production, but makes setting up background services (such as the Flow server) in development way harder than it needs to be. I'm not a devops person, so the extra overhead of trying to figure this all out is significant. Vagrant isn't without its own technical problems, but it mostly Just Works™, and I can do anything to the VM that I'd do on a regular Linux machine. As someone who really doesn't care how these things work under the hood, Vagrant has been a significantly smaller source of friction for me.

Re:Things I Wish I'd Known Before Using Vagrant by mschuster91 on Friday October 27, 2017 @06:29PM (#15572717)
> Docker requires everything to fit into a "one container per service, one process per container" model, which is a really good idea in production, but makes setting up background services (such as the Flow server) in development way harder than it needs to be.

No, it does not. I use Docker as vagrant replacement too, and use a self-written bash script as "init script" that:

1) launches all services required (e.g. apache, mysql, sshd, elasticsearch) by running "service XYZ start"

2) records the pidfiles of each service (/var/run/xyz.pid)

3) sleeps 10 seconds, waits for all the pids having exited - if yes, exit the initscripts, if not, go back to #3

4) on SIGTERM/SIGINT, gracefully shut down the services in the correct order (e.g. apache/php first, then elasticsearch, then mysql); the watcher loop of #3 will detect all services having shut down and exit cleanly

This way I have exact reproduction of a real target server and don't have to deal with the myriad of issues that arise with docker-compose and "custom networks". Also, the documentation on how to set up a production server, especially the required OS packages, is embedded right in the Dockerfile (or, as I put the setup script in its own file, in this one). Build time for an image with identical functionality is approximately equal to what it was with Vagrant.

In contrast to vagrant, once you build that image initially it starts up way faster (10s for a LAMP+es stack), and provisioning it is a breeze compared to puphpet or whatever is the trend now. And you don't have to update your setup script unless the base OS changes, as compared to puphpet+vagrant - in fact I can use nearly the same setup and init script across stuff as old as Debian 6 (some ancient proprietary software I had to dockerize) over Ubuntu 16.04 and as brand new as Debian nightly.

Re:Things I Wish I'd Known Before Using Vagrant by RussianCow on Saturday October 28, 2017 @04:59PM (#15576746)
I used the wrong wording: I should have said that Docker encourages one process per container, not that it requires it. It's possible to do most of the same things with Docker as you can do with a VM, including implementing a full-blown init system, it's just a matter of effort.

Having said that, what you did is definitely non-trivial (at least it would be for me), and you've basically re-implemented all of the stuff Vagrant gives you for free, for a pretty marginal benefit (IMO). Maybe that setup works better for you, but I don't understand why I should go through all that effort when Vagrant Just Works™ most of the time, and Docker for Mac runs everything through a VM anyway.

Re:Things I Wish I'd Known Before Using Vagrant by mschuster91 on Saturday October 28, 2017 @05:29PM (#15576815)
> but I don't understand why I should go through all that effort when Vagrant Just Works™ most of the time

Problem with Vagrant is you can't take the VM you created and deploy it on any random Linux server (or random Docker-hosting cloud provider) - while a pure Docker solution can be deployed literally anywhere with Docker support, as long as you give it a way to persist the data directories of the services. docker-compose is a hit-and-miss across hosters, and you can't use it on DC/OS or Kubernetes environments.

I use my script collection mainly for dev environments, but it's useful when you want to spin up QA/dev instances without having to provision real servers.

Re:Things I Wish I'd Known Before Using Vagrant by anaganisk on Friday October 27, 2017 @11:32PM (#15573860)
can i see the init script seems useful
Re:Things I Wish I'd Known Before Using Vagrant by mschuster91 on Saturday October 28, 2017 @07:11AM (#15574726)
Unfortunately it's corp stuff and needs a bit of cleanup. But I'll try to get it open sourced - can you send me a reminder email? My email's in my profile.
Re:Things I Wish I'd Known Before Using Vagrant by cytzol on Friday October 27, 2017 @10:38AM (#15568750)
I'm far more familiar with Vagrant than Docker, so there may be Docker solutions for these problems. But I use Vagrant to:

- Test my software on a "fresh" Linux installation, to ensure it doesn't have any hidden dependencies

- Test my software with different filesystem layouts and (soon) different filesystems, without having to pollute my own filesystem with hundreds of test files

- Automatically install a set of global commands in the VM (such as "b" to do a complete build) and display help text as soon as a user runs "vagrant ssh", so a new developer can quickly get up to speed

It's been pretty good!

Re:Things I Wish I'd Known Before Using Vagrant by djsumdog on Friday October 27, 2017 @10:41AM (#15568786)
It seems like the author was using Vagrant to set up their base Docker machine.

So yes, the author could have run everything on Docker locally, but this was to setup those Docker clusters (Kubernetes and OpenShift).

I did the same thing when experimenting with DC/OS. Running a small cluster on my developer box with 32GB of ram was cheap. Running the same cluster on DigitalOcean gets very expensive:

http://penguindreams.org/blog/installing-mesosphere-dcos-on-...

Re:Things I Wish I'd Known Before Using Vagrant by cosarara97 on Friday October 27, 2017 @10:24AM (#15568582)
Vagrant gives you a full VM with a traditional init system. Docker is usually used without an init (or a very dumb init), so you'll have different containers for each service. It's a very different way of working, and I'd argue vagrant's is simpler and easier to understand, but less scalable.
Re:Things I Wish I'd Known Before Using Vagrant by bauerd on Friday October 27, 2017 @10:26AM (#15568609)
Yeah I understand the difference between the two but I was wondering why people prefer Vagrant over Docker for development environments.
Re:Things I Wish I'd Known Before Using Vagrant by dasil003 on Friday October 27, 2017 @12:26PM (#15569872)
If I'm deploying to VMs then I prefer Vagrant, if I'm deploying containers then I prefer Docker. It's all about dev/prod parity, at least at the 30,000' view, once you get into specific use cases there may be reason to mix and match.
Re:Things I Wish I'd Known Before Using Vagrant by mitchty on Friday October 27, 2017 @10:32AM (#15568689)
For me, because docker doesn't do jack to help with developing in the kernel.
Re:Things I Wish I'd Known Before Using Vagrant by dominotw on Friday October 27, 2017 @11:07AM (#15569101)
I think this is one of the edge cases where vagrant is useful over docker. Most ppl here don't do kernel dev though.
Re:Things I Wish I'd Known Before Using Vagrant by pizza234 on Friday October 27, 2017 @12:00PM (#15569656)
At my company we need to have virtual machines as close as possible (software wise) to our production environment, including the kernel version.
Re:Things I Wish I'd Known Before Using Vagrant by stephenr on Friday October 27, 2017 @01:39PM (#15570549)
Because we want a full VM, to very closely mimic production.
Re:Things I Wish I'd Known Before Using Vagrant by scaryclam on Friday October 27, 2017 @02:35PM (#15571029)
I use both Vagrant and docker for local Dev work. I've found that we have far less problems with the vagrant box (we link a bunch of projects into a single box to save RAM) than the docker compose setup. We're now looking into a minikube + rkt option, since it's docker daemon itself, not the compose part that makes it painful. Hopefully we can find that sweet spot between working nicely and resource preservation that we want.
Re:Things I Wish I'd Known Before Using Vagrant by dominotw on Friday October 27, 2017 @11:06AM (#15569085)
Me too. I use docker4mac now. Never had to use vagrant again.

I know docker gets a lot of hate here but docker4mac is one one the best pieces of software i've used in a my 10 yr career. It totally changed the way i set my dev environments, think about software development/deployment.

I am so glad they are going to support kubernetes now so I can do local-> staging-> prod seamlessly .

Re:Things I Wish I'd Known Before Using Vagrant by octalmage on Friday October 27, 2017 @12:09PM (#15569738)
Same here, been using docker-compose for development and testing and it's been great. Spinning up 4 servers with docker uses much less space and memory than 4 vagrants. It's also much quicker to provision and get started.
Re:Things I Wish I'd Known Before Using Vagrant by Willson50 on Friday October 27, 2017 @10:20AM (#15568529)
Snapshots are pretty useful, I miss those.
Re:Things I Wish I'd Known Before Using Vagrant by recursive on Friday October 27, 2017 @10:46AM (#15568853)
I'm not super familiar with Vagrant or docker. But I've used vagrant before to do linux development on a windows machine. AFAIK that's not even related to anything docker claims to be able to do.