I mounted the container with this parameter:
-v /home/test/:/home/test
Inside /home/test in the host there is a symbolic link pointing to a /mnt/ folder.
But that link, although can be seen where is pointing to, seems broken inside the container:
root@f93f72b45013:/var/www/html# cd /home/test/
root@f93f72b45013:/home/test# ls -lrt
total 11956
lrwxrwxrwx. 1 root root 40 Jul 20 15:55 file -> /mnt/mountedfile/
root@f93f72b45013:/home/test# ls -lrt file/*
ls: cannot access file/*: No such file or directory
Is that even possible to be done in docker? I am not sure if is there a way to do it.
I know I can just directly mount where the symbolic link is pointing at but I was just wondering if this is possibe.
Symlink is a big challenge inside docker. In your case you can mount both directorires
For symbolic links to work both inside and outside the container have to be absolute paths and use exactly the same names.
In general symlinks does not work inside docker. I found this the hard way.
One solution is to make Docker mount the original file, but use
readlink -f
which prints the file's actual location. This way, you can still reference the symlink location in your command, e.g.docker run -it -v $(readlink -f /home/test/):/home/test/ ...