📚 Mount Multiple NFS Volumes in Docker Compose
If you want more than one NFS share available to different containers, here's how:
Example: docker-compose.yml
version: '3.8'
services:
app-one:
image: my-first-app
container_name: app-one
volumes:
- nfs-storage-one:/data
ports:
- "8081:8080"
restart: unless-stopped
app-two:
image: my-second-app
container_name: app-two
volumes:
- nfs-storage-two:/data
ports:
- "8082:8080"
restart: unless-stopped
volumes:
nfs-storage-one:
driver: local
driver_opts:
type: "nfs"
o: "addr=192.168.100.11,nfsvers=4,hard,timeo=600,retrans=2"
device: ":/mnt/hdd-storage/nfs-share-one"
nfs-storage-two:
driver: local
driver_opts:
type: "nfs"
o: "addr=192.168.100.11,nfsvers=4,hard,timeo=600,retrans=2"
device: ":/mnt/hdd-storage/nfs-share-two"
🛠How This Works
🚀 Quick Commands
To start everything:
To check if volumes are correctly mounted:
✅ This allows you to have multiple apps, each with their own NFS storage, clean and scalable.
✅ No manual mount commands needed on the host!
No Comments