How to sync the symbolic link in syncthing Ubuntu + Docker?

Hi, i’m running ST in docker. With binding like:

/root/syncthing/st-sync:var/syncthing

I want to sync folder outside of /root/syncthing/st-sync. I created symlink like:

ln -s /home/ubuntu/linkTest /root/syncthing/st-sync/linkTest

But when i try to add ~/linkTest in ST GUI, i got an error: Failed to create folder root directory mkdir /var/syncthing/linkTest: file exists

Please help me deal with it. Both symlink and destination has needed ownership(user specified in ST compose.yml)

Not this?.. /root/syncthing/st-sync:/var/syncthing

(In your example, you’ve got a relative path for overlay target.)

Unfortunately, that won’t do what you’d like it to do…

As you already know, the linkTest portion of /root/syncthing/st-sync/linkTest is a symlink.

Inside a Docker/OCI container, /var/syncthing/linkTest will still be a symlink. But inside the container the root directory (/) isn’t the same location as the root directory outside of the container.

So since the symlink points to /home/ubuntu/linkTest, it’s what will be expected whenever the symlink is followed inside the container. Or in other words, it’s relative to the container’s view of the world.

You’re asking Syncthing to create a directory ~/linkTest – which in turn means Syncthing will also create its marker folder ~/linkTest/.stfolder – but there’s already an existing file with the same name (your symlink). A symlink and a directory at the path ~/linkTest cannot coexist at the same time.

To include /home/ubuntu/linkTest from the host side, it either must also be mapped/overlayed into the container or it must be moved into /root/syncthing/st-sync.

1 Like