When the network share goes offline... #7351
-
I noticed the other week, after goofing up my NAS temporarily, that when the network share for storage gets unmounted or isn't mounted at boot, Frigate will create a directory /mnt/frigate and use up all the host storage. I've done some searching and from what I gather, the container could be prevented from booting using a script, if the mount directory is not already present. I'm a little out of my depth here as I've not tried setting up scripts in a Docker compose file before. Is there any documentation on this or a resource someone might recommend? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I had a race condition where Frigate would start before fstab would mount my SMB shares causing the host drive to fill. I switched from mounting via fstab to a systemd.mount units and changed the docker ststemd file to require the systemd mount so docker wouldn’t start until the SMB shares mounted. I also made the mount folder immutable using chattr +i command so if the share mount fails no files can be written to that folder. This will keep the host system disk from filling up with recordings. |
Beta Was this translation helpful? Give feedback.
-
Some time ago I've been messing with network shares and fstab. I always ended up spending more time than I should, while the actual fix is very easy and always work. The secret of getting it to work perfectly is:
Here is how my (relevant parts of) services:
frigate:
container_name: frigate
privileged: true
restart: unless-stopped
image: ghcr.io/blakeblackshear/frigate:stable
shm_size: "2048mb" # I guess 2G Should be more than enough
volumes:
- /dev/bus/usb:/dev/bus/usb # passes the USB Coral
- /etc/localtime:/etc/localtime:ro
- ./frigate/config.yml:/config/config.yml # my Frigate config
- ./frigate/db:/db # This must be on local storage
- frigate:/media/frigate # This is using below NFS volume
- ./frigate/labelmap.txt:/labelmap.txt # I renamed/combined some object types
- type: tmpfs # Optional: 4GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 4000000000
ports:
- "5000:5000" # WebUI
- "8554:8554" # RTSP feeds
- "8555:8555/tcp" # WebRTC over tcp
- "8555:8555/udp" # WebRTC over udp
volumes:
frigate:
driver_opts:
type: "nfs4"
o: "addr=192.168.0.123,rsize=32768,wsize=32768,hard,timeo=600,retrans=2,noresvport,nconnect=16,vers=4.1"
device: ":/volume2/frigate" |
Beta Was this translation helpful? Give feedback.
-
Just came here to add my 2 cents. I don't know much about NFS and just started using it (Radarr & Sonarr running outside of my Synology). NFS is weird. Mounting But the timeout options as specified by @erkexzcx don't appear to be honored. As best as I understand it NFS is supposed to double the Pretty sure that means Also, it seems like specifying Keeping Final result is:
I re-enabled NFS on the Synology and Radarr picked up right where it left off within seconds. The one problem is that if the Synology NFS is offline while the container is started, it shows this error: The solution to that little issue is simple:
Edit: realized I was posting to the Frigate Github instead of Stackexchange. This is a top result when searching for "What happens when Docker container when NFS share goes offline" so I even updated this post a few times in case anyone else stumbles upon it like I did. Apologies if I'm stepping on Frigate's toes here. Even though my info is for Radarr/Sonarr, I hope it's useful to Frigate users and anyone else who uses NFS shares with Docker too. |
Beta Was this translation helpful? Give feedback.
Some time ago I've been messing with network shares and fstab. I always ended up spending more time than I should, while the actual fix is very easy and always work.
The secret of getting it to work perfectly is:
Here is how my (relevant parts of)
docker-compose.yml
look like: