Permission denied when sharing home subfolder in ubuntu

Hi all,

Please bear with me as I am new to everything linux. I have a raspberry pi 5 set up to run ubuntu desktop 23.10 after getting it as a gift. I managed to set up syncthing as a docker container using docker compose using the sample here:

    container_name: syncthing
    hostname: syncthing #optional
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - /path/to/syncthing/config:/config
      - /path/to/data1:/data1
      - 8384:8384
      - 22000:22000/tcp
      - 22000:22000/udp
      - 21027:21027/udp
    restart: unless-stopped

With /path/to/data1 being my home directory /home/user etc

However, when I tried to share a folder that is already in the home folder, I get the following error: Failed to create folder root directory mkdir /home/user/folder: permission denied

In the folder path section of Add Folder, I used /home/user/folder as the path and checking the permissions with ls -la everything folder there has the owner as user:user.

If I change the folder path to ~/folder that seems to work but it creates the folder inside syncthing/config which is not what I wanted. The syncthing folder is also owned by user:user.

Have I missed something obvious here? The PUID and PGID seems to point to the correct user when I checked id user

Thanks for any tips on getting this to work.

With your manifest as shown, Syncthing will see the path to your home folder as /data1. Your folder path as configured in Syncthing should then be something like /data1/whatever.

You might want to make sure that PUID and PGID matches your actual user and group ID on the host as well.


Thanks for taking the time to reply, unfortunately, changing the folder path to /data1/folder threw the same error: Failed to create folder root directory mkdir /data1/

Would you mind elaborating how I can check which PUID and PGID would match? Because when I do id user, I tried different PGID, e.g. 100 for users and 1001 for docker and these don’t seem to make a difference.

Either use

id [your username]

which results in something like

uid=1002(eric) gid=1002(eric) groups=1002(Eric)

where the values 1002 in my case are expected to be 1000 in yours. If not, then you’ll have to change the supplied environment variables in the compose config.

Or check the /etc/passwd file for the user in question.

If all that is correct, then I’d make sure that the volume-mapping works. Simply put, you should be able to browse your user’s home directory from /data1 inside the docker container.

docker exec -it syncthing sh

check if /data1 exists

ls -la /

check if your home directory’s content is visible

ls -la /data1

If that also works fine, and the right uid/gid is showing…then it may simply be an input-error in the Syncthing-GUI. If that didn’t work, then I suggest to show the compose file without it being the template:)

I think I have managed to get this to work, I changed the mapping of the volume to /home:/home and now I can sync existing folders and create new ones.

Thanks to everyone who took the time to read and reply.

Hi Lawrence, i’ve the same exact problem here. The only folder i can use is appdata/config. The others give me access denied. In compose file i’ve set volumes as the example /data/user1:/data1 User for syncthing is appuser id 1001 and has all the permissions to data folder


1 Like


So instead of /data/user1:/data1. I changed it to /home:/home and that fixed it. Not sure what made me change that but I think I was just trying things randomly in desperation.

So did you use the UID 1001 and that is working?

thanks now i’ll try your fix. the uid 1001 works, but now only with ~/something …so it writes only in /config syncthing folder. i’ve tried a lot of combination ufff… but nothing works at the moment. i’ll let you know, thank you

ehi lawrence, it works!! i’ve set /data:/data and now syncthing can create subfolders!!

Thank you very much

I wish I could say I knew what I was doing but all that matters is that it now works!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.