I have a bind mount at /home/quant/mounted_folder with a fstab like this:
/mnt/d/some_folder /home/quant/mounted_folder none bind
I can confirm that the folder mounts correctly on the host:
DESKTOP-NHBC022@quant: ~/mounted_folder $ ls
foo.txt bar.txt
Reproducing the problem:
Take this docker-compose.yml
file:
version: "3.3"
services:
env:
image: debian:latest
volumes:
- "/home/quant:/root/host"
The contents of /root/host/code
appears empty inside the container:
DESKTOP-NHBC022@quant: ~ $ docker compose run env bash -c 'ls -al /root/host/code'
total 28
drwxr-xr-x 2 1000 1000 4096 Jun 18 12:28 .
drwxr-xr-x 17 1000 1000 24576 Jun 18 12:56 ..
Workaround:
If I skip the docker-compose and use just docker run, it seems to work:
DESKTOP-NHBC022@quant: ~ $ docker run -v /home/quant/:/root/host debian:latest bash -c 'ls -al /root/host/code'
total 24
drwxrwxrwx 1 1000 1000 4096 Jun 18 08:59 .
drwxr-xr-x 17 1000 1000 24576 Jun 18 13:00 ..
-rwxrwxrwx 1 1000 1000 0 Feb 11 2021 foo.txt
-rwxrwxrwx 1 1000 1000 0 Jun 18 08:59 bar.txt
How can I make sure that mounted paths on the host correctly appear inside the docker container if they're subdirectories of paths mounted in the container?
I'm running docker 20.10.1 on windows 10 WSL.
docker-compose
?