Everyone has been talking about Docker a lot in the last few months - at least everyone at Hacker News (which is half of all geeks on the world I guess). I ignored the hype about Docker at first, because I didn't really get what the benefit is, but recently I got to play with it. I want to share my experience with you, so you don't have to spend a few hours tinkering with it but still know what it is about - and more importantly, what it is for. And while we're at it, I'll explain what Vagrant is, because it's really similar and what I ended up with using for my experiment.
What I was working on recently on a trip to France, was moving the development environment I use at indoo.rs into a "container". So if I ever got a new machine to work on, I just download this container and everything is automatically configured. "Everything" in this case means things like bash configuration (aliases, etc), dependencies (mvn, git, etc) and also downloading all the projects I need to start working efficiently. Within 15 minutes (depending on bandwidth available) I'm able to work like nothing has changed! Now think a little further: not only I can download this container, but all my colleagues can do it too! Instead of reading through our very scattered development environment setup-guides, they only have to download my container and wait for the magic to finish.
My experiment started as a Docker container, but later I decided to use Vagrant because it fits my needs better. Here's how I understand Docker and Vagrant.
Docker
With docker you can easily configure and run images of a Linux system. Think of it as a virtual machine, but a lot more lightweight - similar to chroot ("chroot on steroids").Vagrant
Vagrant is very similar to Docker on a first glance. I'm sure there's a lot more to it if you use it extensively, but I see it as a layer above docker, because it actually allows you to use existing docker images - but that's only optional!Docker vs. Vagrant
So while Docker only looks like a virtual machine, Vagrant actually is one. Vagrant spins up a new virtual machine for every image you start!
Why use a virtual machine like Vagrant does if you can have a lightweight container like Docker? Because Docker only works on a Linux host. There is boot2docker (for Mac and Windows) but for my usecase this didn't work, because you can't mount directories from the host to the container (Docker). That's because boot2docker actually starts a VM in order to run Docker. Already confused?
TLDR; for cross-platform images there's no way around at least one VM.
Use cases
What can you do with those two then? Docker is heavily used for servers in the cloud, because having lightweight images of your system is a good thing if you want to dynamically scale instances up and down. It's also used for making everyone's life easier by offering images with preconfigured common setups of some software: e.g. an image of a webserver which you can start using in a matter of a few minutes.
Vagrant seems to be less targeted at deploying production systems (webservers, etc) but for development systems (your development environment!). I assume it's used for more than that though because it supports deployment to AWS and others out of the box...
By the way, you can also use vagrant boxes with a GUI. I don't plan to add things like eclipse to my box though, because I don't think that'd please everyone. People usually have their own, weird little eclipse setups which I don't want to overrule...
More on the status of my development box / container in another blog post!
No comments:
Post a Comment