I must choose between Docker and VirtualBox

Aw fuck

Maybe you’ve come across the Docker error above before in a Windows environment.

Hardware assisted virtualization and data execution protection must be enabled in the BIOS. See https://docs.docker.com/docker-for-windows/troubleshoot/#virtualization
Code language: JavaScript (javascript)

If you check the link provided by the error, you’ll come across a few different fixes; primarily enabling virtualization. I happen to know for a fact that virtualization is already enabled in my BIOS

Proof for those who are in utter disbelief

What’s most frustrating is that Docker’s documentation doesn’t actually have the fix, my fix, and a fix that might apply to anyone who’s a big enough nerd to be on this page now.

It comes to down to Hyper-V. When docker is installed it’s reliant on Hyper-v, Window’s proprietary virtualization technology, to work.

Ok, so enable Hyper-v, smart guy

And the fix is that easy, if you’re coming across this. Here’s what you’d run in a Powershell window (as admin) to fix the problem

bcdedit /set hypervisorlaunchtype auto
Code language: JavaScript (javascript)

That’s it. There’s a potential fix to your problem if you’re in this mess. Word to the wise: this requires a restart of Windows to take effect.

Here’s where the plot thickens for me. I disabled Hyper-V shortly after I installed Docker. The reason being when Hyper-V is enabled, my VirtualBox VM’s run incredibly slow. A little on-the-nose turtle icon is displayed at the bottom of VirtualBox when this happens

Turtle means slow – screenshot care of https://www.tenforums.com/virtualization/172991-windows-vm-stucks-virtualbox-but-not-vmware.html – user Eiffelsturm

It took me hours to figure out why my VM’s were so slow. I came across a thread much like the one linked in the caption of the previous image, which recommended disabling Hyper-V and voila, problem solved. And here’s that Powershell code if you’re having that problem: (again, as admin)

bcdedit /set hypervisorlaunchtype off
Code language: JavaScript (javascript)

Though this puts me in an impractical situation: I always have to choose between using Docker containers or V-box VM’s at any given time. Or at best having a painfully slow VirtualBox VM and fully functional Docker.

As a full stack developer, even as a hobbyist, I tend to use both environments. If the fix were just as simple as running the command, I wouldn’t even complain. Just run a batch file or something as needed.

A solution I’ve thought that might remove some of this headache is to only run VirtualBox, and create a VM that runs Docker containers. That presents a host of other problems and it would be more convenient to run a Docker container locally via VS Code. Maybe VMWare doesn’t have the problem?

Anyway I’ve mused on this too long. For now I’ll be switching around as needed 🙄

CATEGORIES:

No Responses

Leave a Reply

Your email address will not be published.