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. 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. Jun 7 '18 at 5:44
  • 1
    @xtrchessreal: Sounds like an answer. Would you please write one based on that comment? Thanks. 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.


The answers are a bit incomplete.

Even if QEMU and Docker use separate aspects of the system, they meet at the level of resources, such as storage and networking. The networking is especially interesting. Depending on your usage-patterns in this area, there are potential problems.

Things NOT to compound include advanced network filtering and aliasing, such as non-trivial firewall, and/or floating IP's, vlan and so on.

The result varies unreliable. You may be fine for a while, then one of the updates may contain a change that breaks it all apart. A new idea for how to filter firewall rule, a new network toolchain and so on.

Check your networking with ip a. On my KVM hosts I see vibrXXX bridges, on the docker VM I see dockerYYY bridges. They typically get messed up with my floatZZZ bridges and other stuff if I install both.

Make your backups and be ready to purge and reconfigure or reinstall. I use 'desired state provisioning' to install my machines. This way I can always get from zero to full config in a matter of minutes, after commenting out the suspected culprit.

With a KVM host and a VM with Docker I kept them apart for years now, avoiding problems colleagues faced on the way.

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.