In this episode, I’ll show you how to properly mount NFS shares directly inside your container config, rather than from the underlying host! This moves the mount dependency of your container stack in to your defined configuration file, and is one less thing your underlying hosts need to do, making your Docker hosts more vanilla and stateless. Check it out! Below is the example code.
version: "3.4"
volumes:
plex_plex-data:
external: true
tv-shows:
name: tv-shows
driver_opts:
type: nfs
o: addr=192.168.2.26,nolock,soft,ro
device: :/mnt/RAID5/TV
movies:
name: movies
driver_opts:
type: nfs
o: addr=192.168.2.26,nolock,soft,ro
device: :/mnt/RAID5/Movies
music:
name: music
driver_opts:
type: nfs
o: addr=192.168.2.26,nolock,soft,ro
device: :/mnt/RAID5/General/Music
services:
plex:
image: "linuxserver/plex:latest"
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 5
ports:
- 32400:32400
- 32400:32400/udp
- 32469:32469
- 32469:32469/udp
- 5353:5353/udp
- 1900:1900/udp
volumes:
- plex_plex-data:/config
- tv-shows:/media/TV
- movies:/media/Movies
- music:/media/Music
environment:
- TZ=America/Phoenix
- PUID=0
- PGID=0
Nothing’s easy…
Was getting an error that port 5353 was in use so removed it after seeing that it’s a legacy protocol I probably don’t need.
Now I get this:
docker-compose up
Attaching to plex-plex-1
Error response from daemon: error while mounting volume ‘/var/lib/docker/volumes/movies/_data’: failed to mount local volume: mount :/volume1/data/movies:/var/lib/docker/volumes/movies/_data, data: addr=192.168.1.4,nolock,soft: permission denied
Here’s the volume section of my docker-compose.yml:
volumes:
plex_plex-data:
tv:
name: tv
driver_opts:
type: nfs
o: addr=192.168.1.4,nolock,soft,rw
device: :/volume1/data/tv
movies:
name: movies
driver_opts:
type: nfs
o: addr=192.168.1.4,nolock,soft,rw
device: :/volume1/data/movies
Tried changing PUID/PGID to the ones on my NAS but no difference.
Any idea?
Thanks again
Got it! Needed to add my PC to the list of allowed NFS permissions on the NAS. Thanks…
Good work! Wrangling NFS both from an access and GID/UID perspective can be challenging the first few times; glad you got it sorted out. BTW not sure if this was incomplete from your code snippet, but you want to use `docker-compose -d` (adding the `-d` to your cmd) to ensure it runs in “disconnected” aka daemonized mode. Cheers!
~OMG
I’m actually using Portainer stacks to make things simpler. Used docker-compose just to help debug previous error. This is great stuff, thanks again, really appreciate your help.
Hi – trying to use your video to setup Plex in Docker with my media on a Synology NAS in /volume1/data/tv and /volume1/data/movies. Section is like this:
tv-shows:
name: tv-shows
driver_opts:
type: nfs
o: addr=,nolock,soft
device: :/volume1/data/tv
movies:
name: movies
driver_opts:
type: nfs
o: addr=,nolock,soft
device: :/volume1/data/movies
Everything else exactly the same as your except timezone and PGID/PUID.
Docker-compose error:
external volume “plex_plex-data” not found
I didn’t hear you cover the plex_plex-data volume in your video so not sure what I’m supposed to do with that. Can you explain please?
Also, I notice there’s nothing about permissions to the NAS in the docker-compose file here. Isn’t something needed to authenticate the container to the NAS?
Thanks very much
Great question! You are correct, I did not clarify that bit: The part that’s missing is not the NFS mounts, but the “plex-data” where the persistent Plex application database and config is stored. In my example, I am referring to that volume as “external”. Remove the line “external: true” from the plex-data” volume in the above example code, and you should be good.
Regarding authentication: This is a bit outside of the scope of this guide, as that varies too much per config, and NFS doesnt auth like SMB does. The gist of that is, you need a UID / GID that matches the numerical value of that UID / GID on your NAS. As an example (not recommended to use root, but here we are!) UID 0 and GID 0 always map to the root user on any *nix system, so you could pass PGID=0 and PUID=0 and that will map to root. again, not recommended, but handy for troubleshooting authentication vs UID/GID issues.
Remember, this is NFS mount, not SMB, so it doesnt use the same user/pass auth as SMB shares. If you need to use SMB/CIFS, that’s again out of scope here, but Google is your friend.
Hope this helps!
~OMG
Thanks for the quick response OMG! Will give it a try…