Vagrant, Docker provider, (and Puppet)

30 Jul

While this is not exactly a Web or Data performance post, it is indeed about performance and the speedup of our DEV environments…

Vagrant + docker provider presentation at Docker meetup in Barcelona

Vagrant + docker provider presentation at Docker meetup in Barcelona

 

I regularly use Vagrant to share the DEV VMs among team developers and for open-source projects.  Vagrant allows to share, build, provision server environment in which to run code.  However, as you go adding VMs to your system, it starts consuming resources and making things slow.  After reading about Docker, decided to merge the two.

Docker is virtualization replacement for several scenarios based on Linux containers (LXC)Docker, allows to pack applications along with configuration and OSs without the need of virtualization (for latests Linux kernels).  So containers allow isolation, automation, portability, and sharing.  Many  of the features found in a VM (minus security, migration, etc), but containers runs simple as processes in our system, so no need for reserved resources and competing VMs.  Our Linux kernel scheduler is in charged of deciding when to run and how the distinct processes.  So, besides being more light-weight on our DEV machines, it can allow for example to replicate better a production environment in our laptops.  And many more features…

While Vagrant has an official docker provider, building a Vagrant compatible box from scratch became a challenge.  Couldn’t find a clean, step-by-step instructions.  So decided to build my own, present, and share it!

The source-code for the project can be found at:  https://github.com/npoggi/vagrant-docker

Basically to build a Docker image compatible with Vagrant defaults, the next 7 step need to be performed:

  1. Import image FROM repo:tag
  2. Create vagrant user
    1. create password
    2. sudo permissions and password-less login
  3. Configure SSH
    1. Setup keys
  4. Install base packages
  5. Install Configuration Management system (optional)
    1. Puppet, etc…
  6. Expose SSH port
  7. Run SSH as a daemon

To the the right steps took me a good time of trial an error.  So I hope this save some time to other people interested.

So follow the Presentation:

Clone the repo, and vagrant up