Hi folks,
You all have been instrumental to my self-hosting journey, both as inspiration and as a knowledge base when I’m stumped despite my research.
I am finding various different opinions on this and I’m curious what folks here have to say.
I’m running a Debian server accessible only within the home with a number of docker images like paperless-ngx, jellyfin, focalboard, etc. Most of the data actually resides on my NAS via NFS.
-
Is /mnt or /media the correct place to mount the directories. Is mounting it on the host and mapping the mount point to docker with a bind the best path here?
-
Additionally, where is the best place to keep my docker-compose? I understand that things will work even if I pick weird locations, but I also believe in the importance of convention. Should this be in the home directory of the server user? I’ve seen a number of locations mentioned in search results.
-
Do I have to change the file perms in the locations where I store the docker compose or any config files that don’t sit on the other end of NFS?
Any other resources you wish to share are appreciated. I appreciate the helpfulness of this community.
I wouldn’t worry about mounting your nfs shares directly to those host unless you need to. Compose has an operator similar to k8s that lets docker itself manage the shares, which is insanely useful if you lose your host. Then you don’t have to have piles of scripts to mount them.
version: "3.2" services: rsyslog: image: jumanjiman/rsyslog ports: - "514:514" - "514:514/udp" volumes: - type: volume source: example target: /nfs volume: nocopy: true volumes: example: driver_opts: type: "nfs" o: "addr=10.40.0.199,nolock,soft,rw" device: ":/docker/example"
This is better as well because it prevents the docker from starting if the mount doesn’t work. Some apps will freak out if they loose their data and apps if they index files like jellyfin might start deleting the files from the index as the library is now empty.
NFS mount via docker compose is the best way to go
Keep in mind that if you change your nfs server IP in the compose file, you will also need to delete the associated docker volume with “docker volume rm” before restarting. This is a potential issue if your old nfs server is still active, you’ll still be accessing the old one. If you have a lot of services and occasionally switch nfs servers (I do this for redundancy, they are synced) it might be easier just to mount nfs in the host and do path:path bind mounts.
DNS is of course the preferred approach
I have all external mounts in
/mnt
, if my container needs to use it then it’s in the compose file to use the local mount.All my compose and stacks are in a git repo, the repo lives in my home dir and pulled fromy Gogs server. That only I can access.