Syncthing on Docker using usbhdd

Hey there, i want to start a docker container with the compose code (syncthing/README-Docker.md at main · syncthing/syncthing · GitHub).

---
version: "3"
services:
  syncthing:
    image: syncthing/syncthing
    container_name: syncthing
    hostname: dockerSync
    environment:
      - PUID=1000
      - PGID=1000
    volumes:
      - /media/usbhdd/docker/syncthing/var/syncthing
    network_mode: host
    restart: unless-stopped

/media/usbhdd

is the mountingpoint of my usb hdd

the uid and gid are the ones, wich owns the mounting point.

But after i deploy this i get in the container logs

chown: /var/syncthing: Operation not permitted

You’re missing a colon in your volume description.

Doesn’t fix it. :confused:

No but now you have a volume mount. :slight_smile: Next step is to make sure uid 1000, as syncthing runs under by default, has write permission on the directory you created.

Yep, the User wich chowns the dir hast the uid 1000.

I’m using a Raspberry Pi 4, generated a new user at first boot. (Do Update and Upgrades) Then i installed docker as root and docker-compose (Install the Compose standalone | Docker Documentation). Than deployed portainer (Install Portainer BE with Docker on Linux - Portainer Documentation) Next i created the dir /media/usbhdd and chown’ed it to the generated User. At least i edited the /etc/fstab as root and entered

UID=73FF-FA36 /media/usbhdd exfat defaults,umask=022,users,nofail 0 0

Just to show my steps.

Just in case you weren’t already aware, an OCI container is an isolated environment, so the users inside the container don’t map 1:1 to users on the host OS, i.e., a user named “hostuser” with UID 1000 isn’t the same as a user named “containeruser” that happens to also be assigned UID 1000.

Search this forum for “portainer”, “docker” and “raspberry pi”. There are quite a few earlier posts that might be of help.

(Just my personal $0.02… If the goal of using Portainer and Docker is to learn about containers, that’s great. But if it’s simply to run Syncthing, it’s way overkill and an overly complex setup for a standalone application such as Syncthing that has minimal OS dependencies. Consider following the instructions on https://apt.syncthing.net/ instead.)

$ ls -ld /media/usbhdd

drwxr-xr-x 3 root root 131072 Feb 17 12:51 /media/usbhdd

I’m not sure, but i think this doesn’t look like what it should, right?!

Thanks, but the suggested search just brings me back to this post of you (Search results for 'Portainer docker Raspberry pi' - Syncthing Community Forum).

Sorry, I should have written that better. :smirk:

Search for “portainer”, “docker” and “raspberry pi” separately and it’ll turn up a bunch of earlier posts about working with Syncthing in Docker and also a Raspberry Pi (although not necessarily in combination).

Do the commands umount /media/usbhdd and mount /media/usbhdd return any errors? (The /etc/fstab entry shown above shouldn’t work because the syntax isn’t correct.)

ExFAT doesn’t support Unix file attributes such as ownership, so any chown after a volume is mounted is temporary (i.e. it only lasts as long as the volume is still mounted).

You can specify the desired UID/GID of the mounted exfat filesystem:

UID=73FF-FA36 /media/usbhdd exfat defaults,uid=1000,gid=1000,umask=022,users,nofail 0 0

Hm. I dont get errors.

But i formated the usb drive as ext4. Now it works Like it should.

Thank you very much! :slight_smile:

Didn’t tried this but, thanks! :slight_smile: