Xen & Docker: made for each other!
2015 December Update: check our complete guide to use Docker with XenServer: Docker support in XenServer, the ultimate guide
Containers and hypervisors are often seen as competing technologies - enemies even. But in reality the two technologies are complementary and increasingly used together by developers and admins. This recent Linux.com article talked about this supposed battle, noting however that developers are using Docker in traditional VMs to bolster security. Containers allow users to develop and deploy a variety of applications with incredible efficiency, while virtualization eliminates any constraints and/or exposure to outside attacks.
Uniting these technologies helps developers and system administrators be even more efficient. Let’s take a closer look at how to achieve this with Docker and Xen Project virtualization, and why we expect more and more organizations to use them together in the near future. This will also be a key topic at the September 15 Xen Project User Summit at the Lighthouse Executive Conference Center in New York City. Register today to learn more about enabling Docker in Xen environments for a truly open infrastructure.
Xen in action, lifting Docker which is lifting containers. I heard you like boats. So I put boats on your boat.
What is Xen Project Virtualization?
Xen Project Hypervisor is mature virtualization technology used by many of the world’s largest cloud providers like AWS, Verizon Terremark, Rackspace and many more. Founded in 2003, Xen Project virtualization is proven as a highly reliable, efficient and flexible hypervisor for a range of environments, running perfectly from x86 to ARM.
It's now completely integrated in the Linux upstream and is hosted by the Linux Foundation. The same big cloud users mentioned above also contribute regularly to the project along with many of the world’s largest technology companies, including Citrix, Cavium, Intel, Oracle and more.
Feature updates and broader community collaboration are on the upswing too: more commits, more communication, better integration, new use cases and simpler and more powerful modes, such as PVHVM then PVH.
The core Xen Project team takes security seriously. The technology has also been battle-tested by many in the defense industry including the NSA. Xen Project users have benefited from this for years, and developers building, shipping and running distributed applications will profit as well.
What is XenServer and Xen Orchestra?
XenServer is a packaged product consisting of the Xen Project Hypervisor and the Xen Project Management API (XAPI) toolstack within a performance tuned CentOS distribution. It's free and can be installed in just a few minutes; you can download it from here.
Xen Orchestra (XO) is a simple but powerful web interface working out-of-the-box with XenServer, or any host with Xen and XAPI (the most advanced API for Xen). Take a look on the project website: https://xen-orchestra.com (hey! that's us!) Both of these tool are of course free software.
What is Docker?
In its own words, Docker defines itself as an open platform for developers and sysadmins to build, ship, and run distributed applications. Consisting of Docker Engine, a portable, lightweight runtime and packaging tool, and Docker Hub, a cloud service for sharing applications and automating workflows, Docker enables apps to be quickly assembled from components and eliminates the friction between development, QA, and production environments.
- fast (boot a container in milliseconds)
- simple to use, even in complex workflows
- light (same kernel)
- container density on one host
The other side of the coin:
- all containers rely on the same kernel (isolation, security)
- less maturity than traditional hypervisor (Docker is still young)
- containers are using the same OS on the host (less diversity than hypervisors)
- some friction between developers and admins about its usage: not Docker's fault, more a classical friction when you bring new toys to your devs ;) We'll see why and how to cope with just that below.
Best of Both Worlds
An ideal world would:
Let admins do their admin stuff without constraints and/or exposure to dangerous things.
Let developers do their developer stuff without constraints and/or exposure to dangerous things.
In other words, they’d be able to create really cool workflows. For example:
- An admin should be able to easily create a Docker ready VM running in a hypervisor, with the exact amount of resources needed at a given point in time (he knows the total amount of resources, e.g a VM with 2 CPUs and 4GB of RAM.
- He should delegate (with the same simplicity) this Docker-ready VM to the dev team.
- Developers can use it and play with their new toy, without any chance of breaking stuff other than the VM itself. The VM is actually a sandbox, not a jail; developers can create their containers as they need in this scenario.
Now you can easily imagine other exciting things such as:
- An admin can delegate rollback snapshot control to a developer. If he breaks the VM, he can rollback to the "clean" snapshot -- without bothering the admin staff. Live, die, repeat!
- Need to clone the same container for other tests? One click in a web interface.
- Need to extend the resources of this current VM? One click, in live.
- Ideally, let a developer create its container from the same web interface.
Xen Orchestra: A Bridge Between Docker and Xen
So how do we do all this without creating a brand new tool? As you may guess, the answer is Xen Orchestra, which today achieves much of this. Updates planned for early 2015 will deliver even more efficiencies between the two technologies.
What XO Does Today
Adjust Resources In Live: You can reduce/raise number of CPUs, RAM, etc., while the VM is running! Doing this, you can grow or reduce the footprint of your Docker VM, without interrupting the service. Check it out in a short video here.
Snapshots and Rollback: Snapshots and rollback in XO are totally operational since XO 3.3. Check out how this works in this feature presentation. Coupled with Docker, this is very helpful. When your fresh Dockerized VM is ready, take a snapshot. Then you can rollback when you want to retrieve this clean state. All with just a few clicks and in a few seconds.
Docker-Ready Templates in One Click: This feature will be released this year. In a few words, you can request our template directly from your XO interface, it will be downloaded and operational in your own infrastructure, with a Docker listening and ready for action, in the resources you choose to allocate (CPU, RAM, Disk). No installation: it works out of the box. Read more in this article: https://xen-orchestra.com/blog/import-and-export-vm-in-xo/.
ACL and Delegation: The perfect workflow rest upon integration of ACLs in Xen Orchestra is our current priority. In our case, it allows VM delegation for your team using Docker; the VM can be rollbacked or rebooted without asking you. More info here.
Docker Control from XO: Because we can get the IP of a VM thanks to its Xen tools, we should be able to send command to the Docker API directly through XO. In this way, you'll just have to use one interface for Docker AND Xen (at least, for simple Docker operations). And take the best of XO for both: ACLs, visualization etc. This last feature is not in our current roadmap, but will probably pop up early in 2015!
Docker is a really promising and growing technology. With Docker and Xen on the same team, the two technologies work in tandem to create an extremely efficient, best-of-breed infrastructure. Finally uniting them in one interface is a big leap ahead!
Any question or comment? Go ahead!