sheng-liang / vm

Package and Run Virtual Machines as Docker Containers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RancherVM

Package and run KVM images as Docker containers

How It Works

RancherVM allows you to create a special kind of containers called VM Containers. A VM container looks and feels like a regular container. It can be created from Dockerfile, distributed using DockerHub, managed using docker command line, and networked together using links and port bindings. Inside each VM container, however, is a virtual machine instance. You can package any QEMU/KVM image as RancherVM containers.

RancherVM additionally comes with a management container that provides a web UI for managing virtual machines and accessing the VNC console.

How it works

Run

First, ensure Docker and KVM are both installed on your system. Follow the distribution-specific instructions to ensure KVM works. We only require KVM to be enabled in the kernel. We do not need any user space tools like qemu-kvm or libvirt. On Ubuntu 14.04, you can make sure KVM is enabled by checking that both devices /dev/kvm and /dev/net/tun exist.

You can run RancherVM on RancherOS. If you are running RancherOS 0.3.1 or later, KVM is already enabled in the kernel.

An easy way to run KVM on your Windows or Mac laptop is to use nested virtualization with VMware Workstation or VMware Fusion. Just enable "Virtualize Intel VT-x/EPT or AMD-V/RVI" in VM settings.

Once you have Docker and KVM both setup, run:

docker run -v /var/run:/var/run -p 8080:80 -v /tmp/ranchervm:/ranchervm rancher/ranchervm

and point your browser to https://<KVM hostname>:8080

You can create VM containers through the web UI or create them directly using Docker command line as follows:

docker run -e "RANCHER_VM=true" --cap-add NET_ADMIN -v \
    /tmp/ranchervm:/ranchervm --device /dev/kvm:/dev/kvm \
    --device /dev/net/tun:/dev/net/tun rancher/vm-rancheros

When you run a VM container from the command line, the system prints a path to a Unix socket for VNC console access.

RancherVM collects the command line options to docker run command and pass them to kvm command. For example, the following command creates the exact same RancherOS VM and additionally specifies memory size and virtual CPU count.

docker run -e "RANCHER_VM=true" --cap-add NET_ADMIN -v \
    /tmp/ranchervm:/ranchervm --device /dev/kvm:/dev/kvm \
    --device /dev/net/tun:/dev/net/tun rancher/vm-rancheros -m 1024m -smp 1

Rancher creates 2 IP addresses in the container and that confuses the RancherVM startup script. You need to set the environment variable IP_PREFIX=10.42 to get RancherVM to work under Rancher.

All the core capabilities of RancherVM reside in the VM container. The RancherVM management container (rancher/ranchervm) provides a simple web interface built on the standard Docker API and is not an essential component of the system.

Build VM Images

You can find instructions on how to build images, including Windows images, in the RancherVM Images document.

Networking

The details of how RancherVM configures network for the VM container is documented in RancherVM Networking.

Build from Source

Just type make

RancherVM uses a modified version of noVNC at https://github.com/rancher/noVNC.

About

Package and Run Virtual Machines as Docker Containers

License:Apache License 2.0


Languages

Language:Python 65.3%Language:Shell 15.4%Language:Makefile 11.4%Language:CSS 6.6%Language:HTML 1.3%