froland80 Posted January 27, 2021 Share Posted January 27, 2021 (edited) Hi Everybody! Is there a good way in unraid to converst absolute path symlinks to relative path? Some more context: I would like to use folders/files with symlinks in a docker. However, the symlinks have absolute path, which won't work within docker, unless I give more broad permissions. Thus I would like to convert the existing symlings to relative path. I can give the docker access to the actual (non symlink) files, but their folder structure is not useful in that docker context. This tool seems to be perfect for the job, but not sure if it's even installable in unraid: https://github.com/brandt/symlinks Any thoughts on how to make this symlink tool work in unraid? Any other ideas on how to convert the symlinks to relative path? Thank you! Edited January 28, 2021 by froland80 marking as solved Quote Link to comment
mgutt Posted January 28, 2021 Share Posted January 28, 2021 This is not possible. Docker containers aren't allowed to access paths which aren't mapped. So if you map /container/data to /host/data, the container is not able to reach /host/documents. No matter if absolute or relative path. If this would be possible, this would be a security hole. Quote Link to comment
froland80 Posted January 28, 2021 Author Share Posted January 28, 2021 Thanks, @mgutt. The docker can access the original files, but they are in an inconvenient file/folder structure. Thus, I created a version with symlinks in a better structure. The problem is that the symlinks are absolute path and the docker does not have access to all the parts of the absolute path. So, the docker can't resolve the links, even if it would have access to the files. ...at least that's what I understood from here. So, relative links should make it work or did I miss anything? This tool should do it, but unraid doesn't seem to have the "make" command to install/compile the tool. Can I just compile that on a mac and then transfer it over? Quote Link to comment
mgutt Posted January 28, 2021 Share Posted January 28, 2021 7 hours ago, froland80 said: So, relative links should make it work or did I miss anything? Yes, but only if the target path is inside of the mapped path. Example: /container/data maps to /host/data Relative link: image.jpg Would target: /container/data/image.jpg which maps to: /host/data/image.jpg Would not work: ../images/image.jpg Would target: /container/images/image.jpg which maps to nothing (it stays inside the docker itself). This would only work if you map /container/images to /host/images as well or if you would map /container to /host for much broader access to the host (which was done in the "Plex example"). Depending to your target it's maybe better to create hardlinks to all the files that should be accessible through the container. But note: hardlinks work only for files. But they allow the following: /host/some_files/image.jpg links to /host/images/image.jpg /host/some_files/texts/text.txt links to /host/texts/2021/01/28/text.txt Now you map /host/some_files to the container and it can only access those files. 1 Quote Link to comment
froland80 Posted January 28, 2021 Author Share Posted January 28, 2021 2 hours ago, mgutt said: 10 hours ago, froland80 said: So, relative links should make it work or did I miss anything? Yes, but only if the target path is inside of the mapped path. Agree. Think for my case that would have actually worked. 2 hours ago, mgutt said: Depending to your target it's maybe better to create hardlinks to all the files that should be accessible through the container. Great idea! Used this command to convert my symlinks into hard links and now it works perfectly! Thank you! Marking this as solved. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.