1

Using docker-compose I'm trying to mount my working directory that contains multiple directories and some are symbolic links.

For instance, I want to mount my working directory that has directories A, B, and C. However, directory C is a symbolic link to C:\Users\MyUser\C

Therefore, I would mount my directories like so:

volumes:
  - ../C:/mnt/host/c/Users/MyUser/C/ # Mounting to the symbolic link location
  - ./:/usr/src/app  # My working directory

This works fine. However, the issue is that c/Users/MyUser is dependent on the user that is executing the command. Therefore, a user would have to go in and update the file to something like c/Users/SomeOtherUser for it to still work. In other words, the directory I'm mounting it to is user dependent.

How can I decouple this from the User? It's fine to assume that the directory C will be in the User's Home directory and one level above the current directory. What I want to do is something like:

volumes:
  - ../C:/mnt/host/${PWD}/../C/

However, this won't work as it's not a valid syntax. How can I mount a Volume to the Symbolic Link's location?

Eric
  • 2,008
  • 3
  • 18
  • 31
  • Does this answer your question? [Mount host directory with a symbolic link inside in docker container](https://stackoverflow.com/questions/38485607/mount-host-directory-with-a-symbolic-link-inside-in-docker-container) – STerliakov Oct 10 '22 at 15:59
  • @SUTerliakov, thanks, but no I don't think so. What you linked assumes you can directly reference the absolute path. My issue is that the path is somewhat dynamic as I want to reference the User's home directory. – Eric Oct 10 '22 at 17:18

0 Answers0