Docker volumes are fiddly and just don't work out-of-the-box with WSL. Here's how to fix that...
When using the Windows Subsystem for Linux (WSL), Docker expects volume mounts to be in the format:
/c/Users/brunty/code - however by default in WSL they're in the format:
/mnt/c/Users/brunty/code as WSL is configured to mount drives in
Before Windows 10 1803 you'd have to
sudo mount --bind /mnt/c /c then
cd /c/Users/brunty/code in order to get docker volumes working properly.
Despite knowing that I need to
sudo mount ... and
cd /c/... etc - I'd always forget to do it, and then get confused when nothing was working in Docker. Frustrating when you just want to get stuff done, implicit steps like the ones above just aren't helpful at all.
In versions of Windows after 1803 you can add the following to your
/etc/wsl.conf file: (docs link)
[automount] root = /
This option makes your mount point
/ instead of the default
/mnt and means that you don't need to
/c/path/to/my/thing instead of
Now you can use volume mounts like
.:/app in a
docker-compose.yml file etc without issue.
I'm not sure how I hadn't spotted this before but I found it in a gist while googling thinking "there's got to be a better way of doing this..." and finding the this gist
So thanks to Diego Alvarez (d1egoaz) for that comment! <3