Docker Windows 10 WSL 2 File System Performance

Windows Docker Volumes - Critical Performance issues

Problem Statement

Running Docker Desktop on Windows 10 with volumes shared from a windows power shell via e.g. docker compose using a local (Windows NTFS) partition performs significantly slower than on comparable Unix or Mac systems.

As a "subjective" performance test, phpUnit tests for a Symfony project were used which are rather file intensive as they create some 5000-10000 cache files when the system is warming up.

Rough numbers (repeated from memory as an indication of the differences):

(1) Native Ubuntu 20.0.4, 32 GB RAM, i7 - ca. 10s to run the test suite
(2) Docker on Windows 10, 16 GB, i7 8th gen U,- about 120 s (!)
(3) Docker on Windows 10, 16 GB, i9 10th gen,- about 110 s (!)
(4) HyperV Virtual Ubuntu 20.0.4, on i9 10th gen - about 10 s
(5) Native Mac Air M1, 2021, 16 GB, M1 1st gen - about < 10 s

(Docker context: setup php env via docker compose in the neighoring folder of the source code, even using tmpfs for cache file share)

Solution

If, however, the source code (run-time env) and the docker compose recipe with the volume sharing is accessed not from the windows-mounted NTFS share, but from the WSL2-mounted "local / file share", then the performance is significantly better close to native Unix / MacOs.

Transferring files into the WSL2 share can be done either with Shell CP copies or the magic samba share of WSL2 reacable under \\wsl$

Summary

Docker Desktop with or without WSL2 activated were extremely slow (~ 12 times slower than native experiments) when sharing docker volumes via the Windows file system.

Running starting docker volume shares from within the WSL2 context (Shell and file system) can benefit of a significantly faster near-native file access performance.

Details:

Docker Desktop 4.0.1 (Engine 20.10.8, Compose 1.29.2)
Reference test system: Test suite of about 74 phpUnit tests of a ~100k line Symfony 4.4 php project running on dockers with php7.3.29 (based on original php project php7.3 versions.
Docker compose recipe using

Example of docker compose volume mount in WSL2
Example of docker compose volume mount in WSL2

In other words:

- Run docker compse ... not in the windows context in PowerShell
but
- Run docker compse in WSL2 with files in the WSL2 based local drive or a custom partition directly mounted in WSL2!

The Journey of Data GmbH
Herzog-Wilhelm-Str. 25
80331 München / Munich, Germany
© 2021, Built with Sanity & Gatsby