Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

I chose itsthenetwork/nfs-server-alpine simple because it had double the downloads! It worked great though so that was that.

https://hub.docker.com/r/itsthenetwork/nfs-server-alpine/

The /etc/exports file contains these parameters unless modified by the environment variables listed above:

*(rw,fsid=0,async,no_subtree_check,no_auth_nlm,insecure,no_root_squash)

Notes: 

  • Because we expose the port and docker-ip's can change, you can mount using your local IP, no subdirectory is needed when mounting. Eg: "mount 192.168.1.1:/ /tmp/tmpmount"
  • Just symlink anything you want to be shared under /mnt. For more complex setup, see the docker hub page.
  • I got errors in the log using "CAP_ADD" so I used privileged and that worked 100%.

Docker-Compose:

WD=/opt/nfs
mkdir -p $WD/{mnt,setup}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.7'

services:
 nfs:
    container_name: nfs
    hostname: nfs
    image: itsthenetwork/nfs-server-alpine
    privileged: true
    ports:
      - '2049:2049'
    volumes:
      - type: bind
        source: /opt/nfs/mnt/
        target: /nfsshare

    environment:
      - 'TZ=America/Whitehorse'
      - 'SHARED_DIRECTORY=/nfsshare'


EOF
chmod +x docker-compose.yaml

SystemD:

WD=/opt/nfs/setup
cat << EOF >$WD/nfs.service.setup.sh
cat << EOL >/lib/systemd/system/nfs.service
[Unit]
Description=nfs_Docker
Requires=docker.service network-online.target

[Service]

Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name nfs --project-directory $WD -f $WD/docker-compose.yaml up
ExecStop=/usr/bin/docker-compose --project-name nfs --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable nfs
systemctl restart nfs
systemctl status nfs
EOF
chmod +x $WD/nfs.service.setup.sh
$WD/nfs.service.setup.sh
  • No labels