How to mount multiple NFS shares?

#1

I recently installed RancherOS in a Docker VM on FreeNAS 11.2. I’m using Portainer to manage the containers. Right now I have one share mapped using the rancheros-cloud-config.yml file, which would be fine for containers that I only want to operate and access that share but I would like to be able to access other shares that I already have setup on FreeNAS but I can’t seem to find any recent information on how to properly modify the .yml to allow multiple shares. Every post I’ve found has been several years old or older and the syntax doesn’t seem to exactly match what I have in the file now that works with one share. So what is the best method to mount multiple NFS shares in Rancher? I’ve pasted the text of the .yml file that used for a single share below. I would appreciate it if someone could give me some advice on how to modify this to allow as many shares as I need.

#cloud-config

# /var/lib/rancher/conf/cloud-config.d/nfs.yml

# https://github.com/rancher/os/issues/641
write_files:
  - path: /etc/rc.local
    permissions: "0755"
    content: |
      #!/bin/bash
      [ ! -e /usr/bin/docker ] && ln -s /usr/bin/docker.dist /usr/bin/docker

rancher:
  services:
    nfs:
      image: walkerk1980/rancher-nfs-client
      labels:
        io.rancher.os.after: console, preload-user-images
        io.rancher.os.scope: system
      net: host
      privileged: true
      restart: always
      volumes:
      - /usr/bin/iptables:/sbin/iptables:ro
      - /mnt/nfs-1:/mnt/nfs-1:shared
      environment:
        SERVER: X.X.X.X
        SHARE: /shared_path
#2

Sorry to not be of help but i too am looking for an answer to the same question.

#3

This way no need using additional nfs-client service. It will mount nfs shared directory at ros console started. Is that what you want?

write_files:
- content: |+
    #!/bin/bash
    until ping -c1 172.22.100.101  &>/dev/null; do sleep 1; done
    mount -t nfs4 172.22.100.101:/ /mnt/nfs
    etc....
  owner: root
  path: /etc/rc.local
  permissions: "0755"
#4

Looks to be what we need, I’ll give it a try and let you know.
In your example is 172.22.100.101 the nfs server? And that’s being pinged then the shares are mounted? And more shares can be added under
mount -t nfs4 172.22.100.101:/ /mnt/nfs
mount -t nfs4 172.22.100.101:/share /mnt/in/rancher
?

So i tried adding

write_files:
- content: |+
    #!/bin/bash
    until ping -c1 192.168.1.2  &>/dev/null; do sleep 1; done
    mount -t nfs4 192.168.1.2:/mnt/JailsSSD/Apps /mnt/apps
    mount -t nfs4 192.168.1.2:/mnt/Tank/Media /mnt/media
    mount -t nfs4 192.168.1.2:/mnt/JailsSSD/Downloads /mnt/downloads
    mount -t nfs4 192.168.1.2:/mnt/JailsSSD/VM-Storage /mnt/vms
  owner: root
  path: /etc/rc.local
  permissions: "0755"

to my cloud-config.yml but it did not mount anything,