# TruenNAS NFS-Volume für Container

### TrueNAS NFS Freigabe

[![image.png](https://wiki.folkerts.it/uploads/images/gallery/2023-06/scaled-1680-/ZWXimage.png)](https://wiki.folkerts.it/uploads/images/gallery/2023-06/ZWXimage.png)

### **NFS-Freigabe in Truenas aktivieren**

- Dienst aktivieren
- NFS-Version V4 wählen (default: V3) &gt; System Settings &gt; Services &gt; NFS &gt; Configure

**Für Plex Container:**

- Mapall User + Mapall Group zuordnen
- docker-compose file siehe unten

**Für Ubuntu VM:**

- Maproot User + Group, z,B. "root", zuordnen (UID/GID müssen in identisch sein für TrueNAS und VM)
- Ggfls. Kernel-Modul installieren: `sudo apt-get install nfs-common`
- Mount-Befehl: `sudo mount -t nfs -o rw 192.168.178.201:/mnt/naspool/mediadata_nfs /mnt/mediadata`

###  

### Docker-compose File:

```yaml
---
version: "2.1"
services:
  plex:
    image: ...
    ...
    volumes:
      - mediadata_nfs:/mnt/mediadata_nfs
      
volumes:
  mediadata_nfs:
    driver: local
    driver_opts:
      type: "nfs"
      o: "addr=192.168.178.201,nolock,soft,rw"
      device: ":/mnt/naspool/mediadata"
    
```

Options "o" für NFS-Einbindung -&gt; [https://blog.stefandroid.com/2021/03/03/mount-nfs-share-in-docker-compose.html](https://blog.stefandroid.com/2021/03/03/mount-nfs-share-in-docker-compose.html)

- `nfsvers=3` or `nfsvers=4`
- `nolock` (optional): remote applications on the NFS server are not affected by lock files within the Docker container (only other processes within the container are affected by locks)
- `soft` (optional): the NFS client fails an NFS request after `retrans=n` unsuccessful retries, otherwise it will try indefinitely
- <span data-darkreader-inline-bgcolor="" style="background-color: rgb(191, 237, 210);">`retrans=n`</span> (optional, default 2): specify the number of retries for NFS requests, only relevant if using `soft`
- `timeo=n` (optional, default 600): the NFS client waits `n` tenths of a second before retrying an NFS request
- `rw`: read-write access
- `ro`: read only
- 