I have a single home lab server that I use to run a few VM’s currently. I would like to start migrating to some container use but, will continue to need VM’s as well. So my question is could I run Ubuntu as my host OS, and then install and run KVM for my VM needs and Docker for my container needs.
Before I start moving things I’d like to know if they will coexist nicely on a single Ubuntu server.

Appreciate your thoughts!

  • Yes you can do that. – Stephen Rauch Jun 7 '18 at 4:55
  • I have found no information that suggests any red flags or caution to attaining your goal. You may wish to read KVM, Docker. – xtrchessreal Jun 7 '18 at 5:44
  • 1
    @xtrchessreal: Sounds like an answer. Would you please write one based on that comment? Thanks. – David Foerster Jun 7 '18 at 10:40

Yes, KVM guests (e.g., Windows or OSX running in QEMU, using KVM) and Docker (e.g., Docker CE running containers) run fine all at the same time on the same Ubuntu instance.

Your question basically describes my workload. At this moment I'm running two Android emulators (using hardware virtualization acceleration, which is KVM on Linux), a Windows 10 QEMU guest, an OS X High Sierra QEMU guest, and Docker (installed via these instructions https://docs.docker.com/install/linux/docker-ce/ubuntu/) with their hello world example running, all at the same time on an Ubuntu 18.04 host.

The concise explanation why it works is that virtual machines (QEMU, etc) on Linux use a hypervisor (KVM in the case of QEMU, but Virtualbox and VMWare use different hypervisors) to use your computer's hardware resources, while Docker uses linux namespaces to simply use your currently running kernel's available hardware resources, but segregated from your main operating system.

In that way, KVM guests and Docker actually run using separate technologies and don't really even inter-relate to each other at the kernel level. This is in contrast to the case where you try to use different hypervisors (e.g., QEMU+KVM and VirtualBox) at the same time - that does not work as you can only run one type of hypervisor at a time (though you may run multiple VMs from each type of hypervisor).

There are great explanations of the technology details here: https://stackoverflow.com/questions/16047306/how-is-docker-different-from-a-virtual-machine

  • Thanks for the concise yet detailed response, just the information I needed at this moment. – renegade Aug 31 '18 at 16:10
  • May I ask how you run "Android emulators (using hardware virtualization acceleration, which is KVM on Linux)" in Ubuntu? I fail to create one in VirtualBox at askubuntu.com/questions/1088222/…. I haven't tried it on KVM/QEMU. – Tim Mar 31 '19 at 0:31
  • @Tim - I read that question and won't respond there because I have no experience in that style and would not recommend it. If you have linux running, you may run Android Studio (at least enough to grab the emulator packages from google, or grab them manually - there are Travis Configs that do this - github.com/ankidroid/Anki-Android/blob/master/.travis.yml#L65 - then boot the thing using the Android SDK tools. This is not the solution you may be looking for given how far afield you are using VirtualBox but what I propose is what every Android developer I know does. – Mike Hardy Mar 31 '19 at 14:55
  • Thanks. Do you emulate Android in Ubuntu? What is the software that perform the emulation? – Tim Mar 31 '19 at 14:59
  • I think I explained it with pointers to scripts that will even install it? In the original answer, I explained the hypervisor was QEMU/KVM. I explained my host (Ubuntu). In my comment above I said I use the Google Android SDK packages (their emulator binary, and their emulator packages), with a pointer to a Travis CI config that even gets them all running. So I'm confused what more information you need. – Mike Hardy Apr 1 '19 at 16:49

I have found no information that suggests any red flags or caution to attaining your goal.

I researched on this a bit and found that the kernel component of KVM was built into mainline Linux since 2.6.20 kernel, 18.04 LTS ships with 4.15 kernel. KVM is well integrated into Ubuntu 18.04 LTS.

According to Docker for Ubuntu, Docker is optimized for bare bones servers and VMs.

You can read more about KVM and Docker respectively.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.