📚 How to Mount NFS Storage for Docker Containers (Docker Compose Version)
🧩 Purpose
Configure Docker Compose to automatically mount an NFS share as a volume into your containers without manually mounting it on the host.
1. Prerequisites
Know your NFS server and export path.
Example:
2. Example docker-compose.yml
version: '3.8'
services:
my-app:
image: my-docker-image
container_name: my-app
volumes:
- my-nfs-storage:/app/data
ports:
- "8080:8080"
restart: unless-stopped
volumes:
my-nfs-storage:
driver: local
driver_opts:
type: "nfs"
o: "addr=192.168.100.11,nfsvers=4,hard,timeo=600,retrans=2"
device: ":/mnt/hdd-storage/my-nfs-share"