Scott Hanselman

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

November 20, 2017 Comment on this post [29] 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

nyancat!

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
Hosting By
Hosted in an Azure App Service
November 20, 2017 8:28
That's it! I'm now officially a dark matter developer. I'm crossing over. Adios!
November 20, 2017 8:37
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?
FM
November 20, 2017 10:00
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?
November 20, 2017 10:31
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.
November 20, 2017 10:48
Does this worki on Home too, or you still need Pro?
November 20, 2017 10:48
What does "latest version of Windows" mean in this context? Fall Creators Update or the latest Insider build?
November 20, 2017 10:52
To answer my own question: The screenshot of the Docker configuration dialog mentions the Fall Creators Update...
November 20, 2017 12:06
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.
mk
November 20, 2017 13:30
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!
November 20, 2017 13:56
I for one welcome our new Whale Overlords.
November 20, 2017 20:36
I would love to deploy containers to my friends computers that I have windows 10 home ,Not pro.
Is this possible?
November 21, 2017 3:19
They just "moved" the virtual machine "inside" hyper -v, so you still need Hyper-V on and Windows 10 PRO. not a big deal
November 21, 2017 6:05
Liam: It appears that even when they won't use Hyper-V, their startup still requires it. Lame. But it's beta software. /shrug
November 21, 2017 13:47
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 :)
Ian
November 21, 2017 14:06
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.

November 22, 2017 1:07
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.
November 22, 2017 13:22
I was too under the impression that Linux Containers on Windows are run on a very thin Linux Kernel hosted in a Hyper-V.
Dan
November 22, 2017 18:27
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.
November 22, 2017 19:56
@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
November 22, 2017 20:05
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
November 23, 2017 5:26
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.
https://docs.docker.com/engine/installation/windows/docker-ee/

And I've been using EE preview. So, I wonder if this is still yet possible with Server 1709?
November 25, 2017 20:56
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.
November 26, 2017 7:57
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.
November 26, 2017 8:57
It seems this does not support "privileged mode": minishift/minishift#1588 (comment) ? Will have to test more...
November 26, 2017 10:54
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.
November 28, 2017 4:44
When using Windows containers, "docker create" will create a windows VM but "docker-machine create" will create a Linux VM.

November 28, 2017 4:47
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".
December 03, 2017 4:46
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.
December 04, 2017 21:28
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.

Comments are closed.

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