While this is not exactly a Web or Data performance post, it is indeed about performance and the speedup of our DEV environments…
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:
- Import image FROM repo:tag
- Create vagrant user
- create password
- sudo permissions and password-less login
- Configure SSH
- Setup keys
- Install base packages
- Install Configuration Management system (optional)
- Puppet, etc…
- Expose SSH port
- 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