Virtualization on Windows 10 with Virtual Box, Hyper-V and Docker Containers

0
Share this on .. Tweet about this on TwitterShare on LinkedIn10Share on Facebook5Share on Google+2Email this to someoneShare on Tumblr0Buffer this page

Recently I started working on a brand new HP ZBook 15-G3 with Windows 10 Pro. And I immediately tried to return to the state I had my previous Windows 7 laptop in: Oracle Virtual Box for running most software in virtual machines, using Docker Machine (and Kubernetes) for running some things in Docker Containers and using Vagrant to spin up some of these containers and VMs.

I quickly ran into some issues that made me reconsider – and realize that some things are different on Windows 10. In this article a brief summary of my explorations and findings.

  • Docker for Windows provides near native support for running Docker Containers; the fact that under the covers there is still a Linux VM running is almost hidden and from command line (Powershell) and a GUI I have easy access to the containers. I do  not believe though that I can run containers that expose a GUI – except through a VNC client
  • Docker for Windows leverages Hyper-V. Hyper-V lets you run an operating system or computer system as a virtual machine on Windows. (Hyper-V is built into Windows as an optional feature; it needs to be explicitly enabled) Hyper-V on Windows is very similar to VirtualBox
  • In order to use Hyper-V or Virtual Box, hardware virtualization must be enabled in the system’s BIOS
  • And the one finding that took longest to realize: Virtual Box will not work if Hyper-V is enabled. So the system at any one time can only run Virtual Box or Hyper-V (and Docker for Windows), not both. Switching Hyper-V support on and off is fairly easy, but it does require a reboot

Quick tour of Windows Hyper-V

Creating a virtual machine is very easy. A good example is provided in this article: https://blog.couchbase.com/hyper-v-run-ubuntu-linux-windows/ that describes how a Hyper-V virtual machine is created with Ubuntu Linux.

I went through the following steps to create a Hyper-V VM running Fedora 26. It was easy enough. However, the result is not as good in terms of the GUI experience as I had hoped it would be. Some of my issues: low resolution, only 4:3 aspect ratio, I cannot get out of full screen mode (that requires CTRL-ALT-BREAK and my keyboard does not have a break key. All alternative I have found do not work for me.

    • Download ISO image for Fedora 26 (Fedora-Workstation-Live-x86_64-26-1.5.iso using Fedora Media Writer or from https://fedora.mirror.wearetriple.com/linux/releases/26/Workstation/x86_64/iso/)
    • Enable Virtualization in BIOS
    • Enable Hyper-V (First, open Control Panel. Next, go to Programs. Then, click “Turn Windows features on or off”. Finally, locate Hyper-V and click the checkbox (if it isn’t already checked))
    • Run Hyper-V Manager – click on search, type Hype… and click on Hype-V Manager
      image
    • Create Virtual Switch – a Network Adapter that will allow the Virtual Machine to communicate to the world
      image
    • Create Virtual Machine – specify name, size and location of virtual hard disk (well, real enough inside he VM, virtual on your host), size of memory, select the network switch (created in the previous step), specify the operating system and the ISO while where it will be installed from
      image
    • Start the virtual machine and connect to it. It will boot and allow you to run through the installation procedure
    • Potentially change the screen resolution used in the VM. That is not so simple: see this article for an instruction: https://www.netometer.com/blog/?p=1663 Note: this is one of the reasons why I am not yet a fan of Hyper-V
    • Restart the VM an connect to it; (note: you may have to eject the ISO file from the virtual DVD player, as otherwise the machine could boot again from the ISO image instead of the now properly installed (virtual) hard disk
      image

References

Article that explains how to create a Hyper-V virtual machine that runs Ubuntu (including desktop): https://blog.couchbase.com/hyper-v-run-ubuntu-linux-windows/ 

Microsoft article on how to use local resources (USB, Printer) inside Hyper-V virtual machine: https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/learn-more/Use-local-resources-on-Hyper-V-virtual-machine-with-VMConnect 

Microsoft documentation: introduction of Hypervisor Hyper-v on Windows 10: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/

Two article on converting Virtual Box VM images to Hyper-V: https://cloudbase.it/convert-virtualbox-to-hyper-v/ and (better) https://www.groovypost.com/howto/migrate-virtual-box-vms-windows-10-hyper-v/

And: how to create one’s own PC into a Hyper-V VM: http://www.online-tech-tips.com/free-software-downloads/convert-pc-into-virtual-machine/

Rapid intro to Docker on Windows

Getting going with Docker on Windows is surprisingly simple and pleasant. Just install Docker for Windows (see for example article for instructions: https://www.htpcbeginner.com/install-docker-on-windows-10/ ). Make sure that Hyper-V is enabled – because Docker for Windows leverages Hyper-V to run a Linux VM: the MobyLinuxVM that you see the details for in the next figure.

SNAGHTMLcb5d37 

At this point you can interact with Docker from the Powershell command line – simply type docker ps, docker run, docker build and other docker commands on your command line. To just run containers based on images – local or in public or private registries – you can use the Docker GUI Kitematic. It is a separate install action – – that is largely automated as is described here  https://www.htpcbeginner.com/install-kitematic-on-windows/ –to get Kitematic installed. That is well worth the extremely small trouble it is.

image

From Kitematic, you have a graphical overview of your containers as well as an interactive UI for starting containers, configuring them, inspecting them and interacting with them. All things you can do from the command line – but so much simpler.

image

In this example, I have started a container based on the ubuntu-xfce-nvc image (see https://hub.docker.com/r/consol/ubuntu-xfce-vnc/) which runs the Ubuntu Linux distribution with “headless” VNC session, Xfce4 UI and preinstalled Firefox and Chrome browser.

image

The Kitematic IP & Ports tab specify that port 5901 – the VNC port – is mapped to port 32769 on the host (my Windows 10 laptop). I can run the MobaXterm tool and open a VNC session with it, fir 127.0.0.1 at port 32769. This allows me to remotely (or at least outside of the container) see the GUI for the Ubuntu desktop:

image

Even though it looks okay and it is pretty cool that I can graphically interact with the container, it is not a very good visual experience – especially when things start to move around. Docker for Windows is really best for headless programs that run in the background.

For quickly trying out Docker images and for running containers in the background – for example with a MongoDB database, an Elastic Search Index and a Node.JS or nginx web server – this seems to be a very usable way of working.

References

Introducing Docker for Windows: https://docs.docker.com/docker-for-windows/ Documentation

Download Docker for Windows Community Edition: https://www.docker.com/community-edition#/download

Article on installation for Kitematic – the GUI for Docker for Windows: https://www.htpcbeginner.com/install-kitematic-on-windows/ 

Download MobaXterm: http://mobaxterm.mobatek.net/ 

Virtual Box on Windows 10

My first impressions on Virtual Box compared to Hyper-V that for now at least I far prefer Virtual Box(for running Linux VMs).The support for shared folders between host and guest, the high resolution GUI for the Guest, and the fact that currently many prebuilt images are available for Virtual Box and not so many (or hardly any) for Hyper-V are for now points in favor of Virtual Box. I never run VMs with Windows as Guest OS, I am sure that would impact my choice.

Note- once more- that for VirtualBox to run on Windows 10, you need to make sure that hardware virtualization is enabled in BIOS and that Hyper-V is not enabled. Failing to take care of either of these two will return the same error VT-x is not available (VERR_VMX_NO_VMX):

image

Here is a screenshot of a prebuilt VM image running on Virtual Box on Windows 10 – all out of the box.

image

No special set up required. It uses the full screen, it can interact with the host, is clipboard enabled, I can easily toggle between guest and host and it has good resolution and reasonable responsiveness:

image

Resources

Article describing setting up two boot profiles for Windows 10 – one for Hyper-V and one without it (for example run Virtual Box): https://marcofranssen.nl/switch-between-hyper-v-and-virtualbox-on-windows/

Article that explains how to create a Hyper-V virtual machine that runs Ubuntu (including desktop): https://blog.couchbase.com/hyper-v-run-ubuntu-linux-windows/ 

Microsoft article on how to use local resources (USB, Printer) inside Hyper-V virtual machine: https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/learn-more/Use-local-resources-on-Hyper-V-virtual-machine-with-VMConnect 

Microsoft documentation: introduction of Hypervisor Hyper-v on Windows 10: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/

HP Forum Entry on enabling Virtualization in BIOS fo ZBook G2 : https://h30434.www3.hp.com/t5/Business-Notebooks/Enable-hardware-virtualization-on-HP-ZBOOK-15-G2/td-p/5513726 

Introducing Docker for Windows: https://docs.docker.com/docker-for-windows/ Documentation

Download Docker for Windows Community Edition: https://www.docker.com/community-edition#/download

Article on installation for Kitematic – the GUI for Docker for Windows: https://www.htpcbeginner.com/install-kitematic-on-windows/ 

Two article on converting Virtual Box VM images to Hyper-V: https://cloudbase.it/convert-virtualbox-to-hyper-v/ and (better) https://www.groovypost.com/howto/migrate-virtual-box-vms-windows-10-hyper-v/

And: how to create one’s own PC into a Hyper-V VM: http://www.online-tech-tips.com/free-software-downloads/convert-pc-into-virtual-machine/

Share this on .. Tweet about this on TwitterShare on LinkedIn10Share on Facebook5Share on Google+2Email this to someoneShare on Tumblr0Buffer this page

About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press books: Oracle SOA Suite 11g Handbook and Oracle SOA Suite 12c Handbook. Frequent presenter on community events and conferences such as JavaOne, Oracle Code and Oracle OpenWorld.

Leave a Reply