tech-docs

Windows

Docker Desktop

Boot Configuration - Rarely Required

To switch between Docker and VirtualBox on Windows it is necessary to enable / disable Hyper-V.

I’ve made some notes on how to create suitable boot configurations.

Nowadays, I just run with Hyper-V enabled and rarely use VirtualBox.

Engine Configuration

The Docker engine can be configured on Linux by tweaking /etc/docker/docker.json.

This is done through Settings -> GUI (Advanced) on Docker for Windows.

WSL 2 Configuration

Memory

When I switched to WSL 2 my Windows version was 2004, build 19041.

The default memory assigned to the WSL 2 Linux VM was changed to 80% of the host memory in build 19028.

This is something of an issue on my 16GB machine because WSL 2 assigned 13GB to the Linux VM and Linux eats RAM.

A solution to this issue can be found in my WSL notes in the WSL configuration section.

Disk Space

Details about the virtual hard disks can be found in my WSL notes in the WSL configuration section.

Removing Legacy VM and LCOW after switch to WSL2

Since Docker Desktop 2.2.0.0 / 2.3.0.2 the WSL2 integration is preferable to the traditional VM or LCOW.

The hard disks for the legacy VM can be found in C:\%USERNAME%\Public\Documents\Hyper-V\Virtual hard disks.

Bind Mounts

When developing on Windows with WSL 2 then be sure that the bind mounts are within the Linux file system and not on the Windows partition. Bind mounts are much faster for files under /home then /mnt/c and this is especially noticeable for “git” operations.

You can also use bind mounts on Linux itself to facilitate copying of files between Linux distros as described in tips and tricks.

Legacy Setup

These were a little tricky to get working on Windows since the WSL2 implementation uses bind mounts within Linux.

The sections below provides some basic pointers as to what was required in the way of setup on my Windows machine.

Windows User

Create a Windows user called “Docker”.

Share C: Drive

Right-click C: -> Properties -> Sharing -> Share… and give full access to the “Docker” user.

Docker For Windows

Settings -> Shared Drives -> C, providing the Docker username and password

Anti-Virus Exclusion

Norton -> Settings -> Firewall -> Configure Public Network Exceptions -> File and Printer Sharing

Troubleshooting

Upgrade Issue

I switched to WSL 2 with Docker 2.3.0.4 and after getting all of my images + containers + volumes migrated, I attempted an upgrade to 3.1.0. After the upgrade the Docker engine failed to start after 20 minutes so I shut down and went back to it the next day. The following morning the Docker engine failed to start and quickly returned an error message.

After taking backups of everything (e.g. vhdx files for Docker and WSL 2), I stumbled across a thread that suggested deleting the files in \\wsl$\docker-desktop-data\isocache and this actually fixed my issue. I found that there was just enough time after attempting to start Docker to get into the folder and delete the files. Docker re-created the isocache files and then fixed itself.

Quick summary:

Threads on GitHub:

I added some brief comments to say what worked for me in case they are helpful to others.

Pengwin + Windows Terminal

I discovered that running Docker containers from Windows Terminal did not work the same as from a Pengwin window.

When I tried to start any container utilising bind mounts, I got the following error:

docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist:

For standalone containers this was pretty evident but with my Docker Compose script that started a MariaDB container it caused some very strange symptoms and the database was failing to start.

Initially I avoided Windows Terminal and stuck to a Pengwin window but I’ve subsequently migrated my projects to Ubuntu.

Further investigation has shown that so long as WLinux is started when Docker integration is enabled it may work ok?

To potentially fix Pengwin + Docker integration run the command wsl --terminate WLinux and let Docker re-start the WLinux distro.

Linux Containers on Windows

Linux Containers on Windows (LCOW) has been an experimental feature in Docker for Windows.

However, I ran into some issues such as inability to stop Linux containers so I stuck to traditional Linux containers.

Since Docker for Windows (2.2.0.0 / 2.3.0.2) has integration with WSL2, I no longer have a specific use for LCOW.

I’ve made some notes on my experiences with LCOW.

Reference

Docker Toolbox (Legacy)

Docker Toolbox - Docker Toolbox overview

Docker Machine - Get started with Docker Machine and a local VM

Microsoft

Microsoft - Containers on Windows

Microsoft Azure (Mark Russinovich) - Containers: Docker, Windows and Trends

Microsoft Azure - Nested Virtualization in Azure

Hyper-V

InfoWorld - What you need to know about Docker in Windows - e.g. Server Core vs Windows Nano

TechTarget - Differences between Windows Server Containers, Hyper-V Containers and VMs

ITPro Today - Differences between Windows Containers and Hyper-V Containers in Windows Server 2016

Cloudstacking - Running Hyper-V VMware or Xen on an AWS EC2 Instance?