Running Docker-OSX on Windows is now possible using WSL2 (Windows 10/11 + WSL Subsystem).
Running Docker-OSX on Windows is possible using WSL2 (Windows 11 + Windows Subsystem for Linux).
Before continuing, you have to check your Windows 10 versione, in fact you need 20175 build or higher. If you are on Windows 11 you can continue it without care about your version.
You must have Windows 11 installed with build 22000+ (21H2 or higher).
Ensure you have enabled the features on your Windows. Search on start "Turn Windows Features on or off" and check these checkbox:
First, install WSL on your computer by running this command in an administrator powershell. For more info, look [here](https://docs.microsoft.com/en-us/windows/wsl/install).
This will install Ubuntu by default.
```
Windows Subsystem For Linux
Windows Hypervisor Platform
Virtual Machine Platform
wsl --install
```
Enabling all the options above, you will have WSL on your Windows OS and the third party application for virtualization like VMWare, VBox, etc...
You can confirm WSL2 is enabled using `wsl -l -v` in PowerShell. To see other distributions that are available, use `wsl -l -o`.
After that, you need to have a version 2 WSL Distro installed, check [this link to upgrade from WSL1 to WSL2](https://docs.microsoft.com/en-us/windows/wsl/install#upgrade-version-from-wsl-1-to-wsl-2) in case you have already installed WSL Distro.
If you have previously installed WSL1, upgrade to WSL 2. Check [this link to upgrade from WSL1 to WSL2](https://docs.microsoft.com/en-us/windows/wsl/install#upgrade-version-from-wsl-1-to-wsl-2).
After WSL installation, go to C:/Users/<Your_Name>/ and add `nestedVirtualization=true` to the end of the file (If the file not exist, create it).
After WSL installation, go to `C:/Users/<Your_Name>/.wslconfig` and add `nestedVirtualization=true` to the end of the file (If the file doesn't exist, create it). You may need to select "Show Hidden Files" and "Show File Extensions" in File Explorer options.
The result should be like this:
```
[wsl2]
nestedVirtualization=true
```
Go to your WSL Distro and check if KVM is enabled by using `kvm-ok` command, the output should be like this:
Go into your WSL distro (Run `wsl` in powershell) and check if KVM is enabled by using the `kvm-ok` command. The output should look like this:
```
INFO: /dev/kvm exists
KVM acceleration can be used
```
It's time to download and install [Docker for Windows](https://docs.docker.com/desktop/windows/install/).
Now download and install [Docker for Windows](https://docs.docker.com/desktop/windows/install/) if it is not already installed.
After installation, go to Setting and check these 2 checkbox:
After installation, go into Settings and check these 2 boxes:
```
General -> "Use the WSL2 based engine";
Resources -> "Enable integration with my default WSL distro"
Resources -> WSL Integration -> "Enable integration with my default WSL distro",
```
Ensure `x11-apps` is installed, in case use the command `sudo apt install x11-apps -y`
Ensure `x11-apps` is installed. Use the command `sudo apt install x11-apps -y` to install it if it isn't.
From now, you have 3 way to get video output:
Finally, there are 3 ways to get video output:
- WSLg: is the one I use, actually is not perfect, ex. keyboard is not fully passthrough or you will see second mouse on the desktop! [Here the issue on WSLg](https://github.com/microsoft/wslg/issues/376)
- Desktop Environment: this will give you a full linux desktop expirience but it will use a little bit of resources "RAM, CPU, GPU, etc..". I will attach an example guide but you will find a tons of guide to set a DE. [DE Example](https://www.makeuseof.com/tag/linux-desktop-windows-subsystem/)
- VNC: You can add -vnc argument to qemu and connect to your VM via VNC Client. [Here how to](https://wiki.archlinux.org/title/QEMU#VNC)
- WSLg: This is the simplest and easiest option to use. There may be some issues such as the keyboard not being fully passed through or seeing a second mouse on the desktop - [Issue on WSLg](https://github.com/microsoft/wslg/issues/376) - but this option is recommended.
To use WSLg's built-in X-11 server, change these two lines in the docker run command to point Docker-OSX to WSLg.
```bash
-e "DISPLAY=${DISPLAY:-:0}" \
-v /mnt/wslg/.X11-unix:/tmp/.X11-unix \
```
- VNC: See the [VNC section](#building-a-headless-container-which-allows-insecure-vnc-on-localhost-for-local-use-only) for more information. You could also add -vnc argument to qemu. Connect to your mac VM via a VNC Client. [Here is a how to](https://wiki.archlinux.org/title/QEMU#VNC)
- Desktop Environment: This will give you a full desktop linux experiencem but it will use a bit more of the computer's resources. Here is an example guide, but there are other guides that help set up a desktop environment. [DE Example](https://www.makeuseof.com/tag/linux-desktop-windows-subsystem/)
## Additional boot instructions for when you are [creating your container](#container-creation-examples)