Docker Desktop just got more pricey again. Let’s explore some ways to replace at least part of its functionality like running docker containers and doing networking. This guide will be for the Windows operating system, as it is the one where users will most likely use Docker Desktop.

We will use the Hyper-V virtualization solution already present on Windows and show how to integrate your Docker Desktop replacement into your environment.

Running Your Containers On Hyper-V

Windows cannot run Docker containers natively as Docker relies on Linux kernel features. So we will have to use a VM with a Linux distribution to run them. Docker Desktop does the same thing but hides it behind a nice graphical user interface.

There are some virtualization solutions for Windows like VMWare Workstation, VirtualBox, and Hyper-V. We choose Hyper-V as it comes with Windows (11 Pro) and is free. VMWare by Broadcom and VirtualBox by Oracle have their own licensing issues by now.

Enable Hyper-V on Windows

This is actually best explained by Microsoft themselves: Enable Hyper-V on Windows | Microsoft Learn.

Import A Docker Host System

You can basically choose any Linux distribution as your Docker host system, but I like Clear Linux as it is super fast. It adds minimal overhead to the containers and is heavily optimized for newer Intel processors. If you are not running an Intel processor, try Arch Linux or Alpine for speed.

Set Up The VM

Download the ready-made Hyper-V image and follow the installation guide.

Make the Network Permanent

By default, the new VM gets one network interface behind a simulated NAT (the Default Switch). That’s very helpful for internet access, but not great if you want to access the machine via SSH. Also, you surely want to use the machine independently of the location of your laptop. So we add a new network connection that connects to a virtual host-only network. Here, our IP addresses always stay the same and you can connect regardless of your internet connection.

In the Hyper-V Manager, open the machine settings while the VM is switched off and add a new network connection:

Pick the virtual switch “Host Only”:

Now we have to fix the IP of the host system. Go to the advanced network settings in the Windows Settings and edit the adapter settings of your vEthernet (Host Only) adapter. There, open the TCP/IPv4 settings:

Switch the settings to “Use the following IP address” and pick an address and netmask of your choice. If unsure, just copy what’s in the picture. Hit ok until everything is saved.

Now the IP of the Windows VM host is fixed. We have to do the same for the VM. Go to the Hyper-V Manager and “Connect” to your recently created VM. Log in as root and add the following file (use vi):

/etc/systemd/network/70-static.network
[Match]
Name=eth1

[Network]
Address=10.49.0.12/24

Save the file.

Install Docker

While we are at it, let’s install docker on the VM. As root, do:

swupd update
swupd bundle-add containers-basic
sudo systemctl start docker
sudo systemctl enable docker
# make docker available to your user, add the username to the docker group
usermod -a -G docker benjamin

Install SSH

For easier access we install SSH on the VM. As root, do:

swupd bundle-add openssh-server

Ideally you now place your public ssh key into ~/.ssh/authorized_keys. Don’t forget the 0600 file permissions. ( chmod 600 ~/.ssh/authorized_keys ).

You should now be able to access the VM from Powershell using your private SSH key:

ssh -i .\.ssh\id_ed25519_tng benjamin@10.49.0.12

Bonus: Add VM Hostname

Open a text editor ad root and add the following to your hosts file on Windows:

C:\\Windows\\System32\\drivers\\etc\\hosts
10.49.0.12 dockerhost

Bonus: Add SSH config

For easier ssh access, add this to your .ssh/config on Windows:

~/.ssh/config
Host dockerhost
Hostname 10.49.0.12
User benjamin
IdentityFile ~/.ssh/id_ed25519_tng

Now restart the VM.

Graphical User Interfaces

Using SSH access, IntelliJ and it’s derivatives are already able to control Docker on the Hyper-V VM. Visit the Services Tab on the lower left, and add a docker connection:

Then select the docker VM as target:

The SSH config should look like this:

Docker on the Windows Powershell

To make Docker also available on the Powershell, we have to first expose the docker control socket to Windows and then connect a local docker cli.

Make Docker Available On The Network

Now we have to make the docker control socket available to our windows machine. On the VM, open the docker service file as root and modify the ExecStart line to look like this:

/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:4243

Now do a systemctl restart docker.

Exposing the docker socket on a network is normally a bad idea. We get away with it here, as the VM is only directly reachable from our host Windows machine.

Install Docker CLI

We used chocolatey to install docker-cli. Follow their installation guide to get the tool and then do as admin:

choco install docker-cli

Configure Docker CLI

As the docker socket is already exposed, just do:

PS C:\Users\ms_is> docker -H 10.49.0.12:2375 ps

You can omit the host config if you create an environment variable like this: