Search code examples
linuxcontainersdockerlxc

Can Linux Container run on a virtual machine?


As far as I know, Linux container is different from virtual machine. It's lightweight virtualization technology. So I'm wondering if it can be run on a virtual machine which provisioned by hypervisor like xen, kvm or vmware?

I was trying setup a Linux container(docker + LXC userspace tool) on a virtual machine based on zex. It failed.

[root@docker lib]# service docker start
Starting cgconfig service: Error: cannot mount cpuset to /cgroup/cpuset: Device or resource busy
/sbin/cgconfigparser; error loading /etc/cgconfig.conf: Cgroup mounting failed
Failed to parse /etc/cgconfig.conf                         [FAILED]
Starting docker:                                           [  OK  ]

and if trying to run a container:

root@docker lib]# docker run -i -t ubuntu /bin/echo hello world
lxc-start: error while loading shared libraries: liblxc.so.1: cannot open shared object file: No such file or directory
2014/03/27 14:03:27 Error: start: Cannot start container da0d674d3e31a7c36a9e352f64fd84986cbb872e526cb2dd6adb7473d4f5a430: exit status 127

Actually, I followed a blog to do, the author made it, while I screw it.

Any one can explain that? Or simply tell me it can not be ran on a virtual machine. Really appreciate.


Solution

  • Yes, it can. If your VM's operating system supports the appropriate filesystems, and have containers. I suggest you go though as suggested on https://www.docker.io/gettingstarted/ and use a recent Ubuntu release, since that is known to work.