Skip to content

Instantly share code, notes, and snippets.

@BarelyAliveMau5
Last active June 24, 2021 23:54
Show Gist options
  • Save BarelyAliveMau5/67ca55761341b6a2d157495b38621dc1 to your computer and use it in GitHub Desktop.
Save BarelyAliveMau5/67ca55761341b6a2d157495b38621dc1 to your computer and use it in GitHub Desktop.
Installing docker with container isolation in a Windows Server 2016 VM running inside VirtualBox 6.1

One of the requirements to use Docker in Windows with Container Isolation is to enable Hyper-V, this is specified in the official documentation of Microsoft. (Click here if the link is dead).

If you search a lot in the internet, you'll probably find references to "Hyper-V must be enabled in the host machine", however, you might also notice that VirtualBox had a hard time integrating with Hyper-V in the past few years, i tried it myself and lost 2 days trying to figure out why i was getting blue screens all the time. As it turns out, virtualbox 6.1 was STILL having issues with Hyper-V in the host machine, so i had to turn it off in order to use my other VMs.

So i could not enable Hyper-V in the machine running VirtualBox, so what then?

I can tell that Virtualization has to be enabled, and I want my VM running Windows Server capable of using virtualization too, so Nested Virtualization was desired.

I haven't really tested without the "Nested VT-X" option enabled in virtualbox, but i suppose this is mandatory for this tutorial to work. (Note: i enabled this option after installing windows server 2016 and it just worked, the VM was created without nested virtualization enabled.):

enable nested vt-x

Right, what next, then? Enable Hyper-V in the VM!

hyper-v cannot be installed

Oh oops. This cannot be installed either by this UI nor by the powershell command that Microsoft tells us to run (Install-Feature or something)

Okay, so... how to get around this? use DISM

This kinda forces windows to install a feature that it refuses to be installed due to the lack of a explicit SLAT support:

DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V

force enable hyper-v with dism

Don't ask me why this works, i really don't know why, i did not find this anywhere in the internet either, it was pure Go-Horse because Windows works in mysterious ways and spending multiple days with issues like this leaves us with not many other options.

After that, rebooting the VM will be necessary.

hyper-v was installed

Windows tells us Hyper-V was installed, even though Windows complained it couldn't be installed, surprised? Yeah. The fun part is that Hyper-V actually works there, so the previous error was pretty much a mistake or intentionally put there, the real reason is unknown by me though. I'm sure someone will say this is a feature and not a bug.

Okay, the next step is to install docker via powershell. By following microsoft's documentation, its clear we need to first install a module in powershell called "DockerMsftProvider".

In my case, it was not that simple though..

error install-module dockermsftprovider

I simply don't know what's wrong with PSGallery in Windows Server 2016, it refuses to work all the time, even after i remove it.

We need to get rid of this thing because it gives me headache by simply trying to remember how much time i wasted to make this work.

manually adding psgallery-alternative

As i said before, PSGallery shows weird errors even when you're removing it, i don't know what's wrong with this thing, but its fine, even its screaming errors it no longer causes us any harm.

I did search about this issue and i lost more time than i expected, multiple people having similar problems and none of the purposed solutions seemed to work.

After adding our own custom provider for PSGallery (named PSGallery-Alternative), we need to try installing DockerMsftProvider again.

dockermsftprovider installed successfully

And it just works, at least for me it worked, and i hope it works for you too, if it doesn't, try running: [Net.ServicePointManager]::SecurityProtocol = "tls12" like shown in the image.

Finally, we can install Docker using powershell:

docker installed successfully

Now the command docker works via powershell, FINALLY.

docker command working

Took me long enough to solve these problems, I really hope this tutorial helps you solving this particular problem or other related ones.

Ignore this, its a bunch of keywords for search engines to find it:

VirtualBox Windows Server 2016 Docker hyperv windows server 2016 error virtualbox enable hyper-v inside virtualbox vm Hyper-V cannot be installed: The processor does not support second level address translation (SLAT). PowerShell Gallery is currently unavailable. Please try again later. PowerShellGalleryUnavailable,Get-PSGalleryApiAvailability Hyper-V(Installed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment