Docker Community Forums

Share and learn in the Docker community.

How to bind volumes inside the docker wsl

Hi, after a while I decided to give docker for windows a third (or even more :stuck_out_tongue: ) shot as it now supports wsl2. I installed it and all works fine. However, I have a question that I can’t find the answer in the documentation: is it possible to bind volumes in folders inside the docker subsystem?

In documentation best practices is written to not use /mnt/c/users but ~ and nothing more. If I try in a docker compose to write for a volume /root/mydata or /mydata with, for example, mariadb I get errors saying that the directory doesn’t exist even if it’s there. At this point I am very confused how it works, if it can work that way. I know I can still use another wsl, like ubuntu, with the integration but the question remains.

Thanks to anyone who can help.