Scott Hanselman

Docker and Linux Containers on Windows, with or without Hyper-V Virtual Machines

November 20, '17 Comments [38] Posted in Docker | Win10
Sponsored By

Containers are lovely, in case you haven't heard. They are a nice and clean way to get a reliable and guaranteed deployment, no matter the host system.

If I want to run my my ASP.NET Core application, I can just type "docker run -p 5000:80 shanselman/demos" at the command line, and it'll start up! I don't have any concerns that it won't run. It'll run, and run well.

Some containers naysayers say , sure, we could do the same thing with Virtual Machines, but even today, a VHD (virtual hard drive) is rather an unruly thing and includes a ton of overhead that a container doesn't have. Containers are happening and you should be looking hard at them for your deployments.

docker run shanselman/demos

Historically on Windows, however, Linux Containers run inside a Hyper-V virtual machine. This can be a good thing or a bad thing, depending on what your goals are. Running Containers inside a VM gives you significant isolation with some overhead. This is nice for Servers but less so for my laptop. Docker for Windows hides the VM for the most part, but it's there. Your Container runs inside a Linux VM that runs within Hyper-V on Windows proper.

HyperV on Windows

With the latest version of Windows 10 (or 10 Server) and the beta of Docker for Windows, there's native Linux Container support on Windows. That means there's no Virtual Machine or Hyper-V involved (unless you want), so Linux Containers run on Windows itself using Windows 10's built in container support.

For now you have to switch "modes" between Hyper V and native Containers, and you can't (yet) run Linux and Windows Containers side by side. The word on the street is that this is just a point in time thing, and that Docker will at some point support running Linux and Windows Containers in parallel. That's pretty sweet because it opens up all kinds of cool hybrid scenarios. I could run a Windows Server container with an .NET Framework ASP.NET app that talks to a Linux Container running Redis or Postgres. I could then put them all up into Kubernetes in Azure, for example.

Once I've turned Linux Containers on Windows on within Docker, everything just works and has one less moving part.

Linux Containers on Docker

I can easily and quickly run busybox or real Ubuntu (although Windows 10 already supports Ubuntu natively with WSL):

docker run -ti busybox sh

More useful even is to run the Azure Command Line with no install! Just "docker run -it microsoft/azure-cli" and it's running in a Linux Container.

Azure CLI in a Container

I can even run nyancat! (Thanks Thomas!)

docker run -it supertest2014/nyan


Speculating - I look forward to the day I can run "minikube start --vm-driver="windows" (or something) and easily set up a Kubernetes development system locally using Windows native Linux Container support rather than using Hyper-V Virtual Machines, if I choose to.

Sponsor: Why miss out on version controlling your database? It’s easier than you think because SQL Source Control connects your database to the same version control tools you use for applications. Find out how.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Monday, 20 November 2017 04:28:59 UTC
That's it! I'm now officially a dark matter developer. I'm crossing over. Adios!
Monday, 20 November 2017 04:37:03 UTC
Does "Linux Containers on Windows" use the same underlying tech as Windows Subsystem for Linux? E.g., will bug fixes & syscall improvements to the latter impact the former?
Monday, 20 November 2017 06:00:35 UTC
I currently have Windows 10 Pro 1703. I have but don't run Hyper-V. I have VirtualBox installed. Since Docker on Windows currently uses Hyper-V, can I run the hidden VM version or do I have to uninstall VirtualBox?
Monday, 20 November 2017 06:31:40 UTC
Wait, wait. So far, we have not been able to run "native" containers on Windows 10 at all: just Hyper-V isolated containers. Has that changed?

Also, by definition, a container is an isolated group of processes, running on top of the host kernel. So when you say "native Linux Container support on Windows", are these processes running on the Windows kernel, perhaps using the WSL subsystem layer?

I was under the impression that Linux Containers on Windows are run on a very thin Linux Kernel hosted in a Hyper-V VM.
Raj Chaudhuri
Monday, 20 November 2017 06:48:44 UTC
Does this worki on Home too, or you still need Pro?
curious one
Monday, 20 November 2017 06:48:52 UTC
What does "latest version of Windows" mean in this context? Fall Creators Update or the latest Insider build?
Monday, 20 November 2017 06:52:19 UTC
To answer my own question: The screenshot of the Docker configuration dialog mentions the Fall Creators Update...
Monday, 20 November 2017 08:06:00 UTC
The biggest bummer for me is the Hyper-V and HAXM not working together. So if you want to run backend on docker and use Android emulator with acceleration the you are out of luck.
Monday, 20 November 2017 09:30:59 UTC
So does this mean that I won't need Hyper-V any longer if I use LCOW? I installed the Edge Release of Docker for Windows and enabled this new feature but it still pops up with a message if I do not have Hyper-V enabled. Is there something I am missing? Would be awesome if I could have a Windows Machine with VMWare Workstation co-existing with Docker for Windows!
Monday, 20 November 2017 09:56:46 UTC
I for one welcome our new Whale Overlords.
Monday, 20 November 2017 16:36:10 UTC
I would love to deploy containers to my friends computers that I have windows 10 home ,Not pro.
Is this possible?
Jim C
Monday, 20 November 2017 17:30:43 UTC
Great post and interesting topic. I don't think tech is killing curiosity, but the embedded systems that are today's technology might do so. The iPhone or Android don't leave a lot of room for exploration and creativity, and the legacy status of desktop computing does not help. I do think small and cheap systems like Raspberry Pi and Debian/Raspbian have a lot more to offer in terms of figuring out how systems work.Merry Christmas
Monday, 20 November 2017 17:46:00 UTC
Very Nice Article nice Information please visit my website How to Guide
Monday, 20 November 2017 23:19:26 UTC
They just "moved" the virtual machine "inside" hyper -v, so you still need Hyper-V on and Windows 10 PRO. not a big deal
Maxim Gerasimov
Tuesday, 21 November 2017 02:05:11 UTC
Liam: It appears that even when they won't use Hyper-V, their startup still requires it. Lame. But it's beta software. /shrug
Tuesday, 21 November 2017 09:40:43 UTC
That's it! I'm now officially a dark matter developer. I'm crossing over. Adios! mehndi makeup
Tuesday, 21 November 2017 09:47:49 UTC
I'm another person who likes to use VirtualBox and sometimes VMWare rather than the MS HyperV, so this could be great if it means I don't need HyperV to be enabled.

Serious point, I could switch to HyperV for everything if Microsoft would update the HyperV Linux video driver so that it supports resolutions higher than 1080p. I sometimes need a Linux desktop and both VMWare and VirtualBox handle screen resizing transparently. With HyperV (unless it's changed in the last 12 months) I need to edit a config file and then only gain support for relatively low resolutions. I think both those two also support screen scaling, i.e. have 1080p resolution scaled up to fit a 4k monitor so that teeny tiny icons are a bit bigger. That would also be an acceptable compromise and actually more useful in some cases.

Great blog as usual :)
Tuesday, 21 November 2017 10:06:19 UTC
Greetings to dark matter developers. I really feel with you as I also work with "legacy" ASP.NET (non-core) hosted in App Service backed by WebJobs and Azure Functions and it is really comfortable and feel really appropriate to what I need now.

(Up-to some performance and scalability issues which are on my TODO list anyway.)

I have honestly not collected enough reasons to start working in docker yet.

But do you see my wording? "...yet".

Is something wrong with me? I feel like docker might be response to some of my deep concernes, and I feel like it is a future for me and our team, but I am not able to advocate the added complexity for me now.

And I blame myself for "not getting that". Thanks to you "dark matter guys" I feel less guilty.

So far we all just compile locally, use localdb, connect to some developer instances of queues/tables in azure and we hope all works the same in production and it most of the time does.

Nevertheless, I am eagerly (async) awaiting Scott's blog posts to see how far from the "ready-for-lazy-Richard" status is the technology around VS2017 and .NET.

And I am patiently waiting. Dear "Microsoft with all the great Scotts", please keep up the great and hard work. You have my trust even though I plan to stay behind a bit.

Richard Vondráček
Tuesday, 21 November 2017 17:06:02 UTC
thank you friend
Tuesday, 21 November 2017 21:07:58 UTC
To those questioning Hyper-V, remember that to run Windows containers (on Windows 10), it still runs the container within the context of a Hyper-V "shim", referred to as Hyper-V isolation (not a full VM, though). The Linux containers used to run within a complete VM. I'm guessing when running a Linux container, it's running each container inside its own shim.
Richard Gavel
Wednesday, 22 November 2017 09:22:08 UTC
I was too under the impression that Linux Containers on Windows are run on a very thin Linux Kernel hosted in a Hyper-V.
Wednesday, 22 November 2017 09:27:40 UTC
I was too under the impression that Linux Containers on Windows are run on a very thin Linux Kernel hosted in a Hyper-V
Wednesday, 22 November 2017 14:27:48 UTC
Requirement of Hyper-V is the ONLY reason I'm not using docker for windows. I use virtualbox for work all the time, and they don't work together at all.

This is very unfortunate, MS should simply switch the hypervisor on Hyper-V to the same type VirtualBox uses and let them co-exist. I really don't care for this type of optimization on a dev box, I just need them to run.

Until MS removes this limitation, docker for windows is a no-go.
Wednesday, 22 November 2017 15:56:50 UTC
@Richard Vondráček I too would like a compelling reason to use docker (or any container) on Azure. I really can't see it. With Docker I need to maintain my images, I need to deploy to a docker image store and then maintain it.

It's much easier to use webjobs and webapps, they can be scaled, and because you can have multiple web sites per app service they can contain highly focused "services".

@Scott - I'd like a "why should you bother" with containers post as I really feel I'm missing something here
Wednesday, 22 November 2017 16:05:02 UTC
I basically have the same complaint as others in that Docker still requires Hype-V to be enabled, even with this new beta feature.

Personally, I am a long time user of VMware Workstation and so have no want or need for Hyper-V.

I guess I will have to see if I can get it to work in a VM instead.

I too would also be interested in a "why should you bother" post about containers.

Mike S
Thursday, 23 November 2017 01:26:50 UTC
So, Server 2016 1709 is GUI-less. I'm encountering difficulties in getting LCOW enabled/supported and being able to spin up some of the container examples you showed. I think I've got everything necessary enabled/installed.

When I try to run a container from a linux-based image, it's complaining that, "container <guid> encountered an error during CreateContainer: failure in a Windows system call: No hypervisor is present on this system."

I also discovered this:
Install Docker EE - Windows Server 1709

Docker Universal Control Plane is not currently supported on Windows Server 1709 due to image incompatibility issues. To use UCP, for now please use the current LTSB Windows release and not 1709.

And I've been using EE preview. So, I wonder if this is still yet possible with Server 1709?
E Fisher
Saturday, 25 November 2017 09:51:53 UTC
Wonderful post!!! Genuinely loved this kind of post. Although I want much more information on like precious subject matter.
Saturday, 25 November 2017 09:53:43 UTC
Thanks for publishing this details. I simply wish to let you know that I just look into your site and also I locate it really fascinating and useful. best vitamins for chickens cattle feed
Saturday, 25 November 2017 09:54:41 UTC
Just want to comment on few general things, the website style is perfect, the written content is real great quickbooks help quickbook license quickbooks enterprise support
Saturday, 25 November 2017 16:56:24 UTC
I like the idea of docker containers in general. Haven't explored it that in depth (yet); but I like less pain, less overhead. Reading some responses, looks like there is a Hyper-V requirement there, but I disagree they do not work together. I, too, have used VirtualBox, and it does work well enough. I've even hosted a Hyper-V image on VirtualBox before one one contract I was on, troubleshooting the disk image locally. You can paint yourself in a corner if you choose more proprietary disk image types, but if you stick with the commonly known image types, you're fine. Of course, there are caveats, pros/cons, either way. Choose the best path that meets your needs.
Sunday, 26 November 2017 03:57:22 UTC
I created an issue in our Minikube issue tracker for this: Support for running on Windows using Linux Containers for Windows. Not sure if we can target this any time soon, but at least we can consider it for Minikube and Minishift.
Sunday, 26 November 2017 04:57:44 UTC
It seems this does not support "privileged mode": minishift/minishift#1588 (comment) ? Will have to test more...
Sunday, 26 November 2017 06:54:10 UTC
Back to MobyLinuxVM for now; it does not have shared host folders support, namespacing issues and the privileged mode issue (which is currently necessary for `oc cluster up` to work). Will spend more time on time on this in the near future, but for now I need my current setup as-is.
Sunday, 26 November 2017 11:14:36 UTC
Containers are great for deployments. I'm glad that Microsoft is making them really easy to use.
Tuesday, 28 November 2017 00:44:08 UTC
When using Windows containers, "docker create" will create a windows VM but "docker-machine create" will create a Linux VM.

Tuesday, 28 November 2017 00:47:23 UTC
I should complete the command:

"docker-machine create --driver hyperv --hyperv-virtual-switch lan default"

Use Hyper-V Manager to create a switch that can reach the Internet - otherwise it defaults to "nat".
Sunday, 03 December 2017 00:46:32 UTC
Very Cool
I love it when I see Windows and Linux are coming together.
You can run a Cluster of Linux containers on a Windows machine!
Can't wait for more support in Kubernetes, so we can have Windows machines as Kubernetes Control Planes.
Monday, 04 December 2017 17:28:31 UTC
You do need hyper-v installed, but you can prevent it from being enabled with 'bcedit /set hypervisorlaunchtype off' and a reboot. After that, the check in docker will succeed, but you can run vmware or another vm subsystem.
AJ Lewis
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.