install pihole at docker swarm with nfs share


I’m using portainer

This is my stack

version: "3.7"
services:
  pihole:
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      TZ: 'Asia/Jakarta'
      WEBPASSWORD: 'password'
    volumes:
      - 'pihole.vol:/etc/pihole/'
      - 'pihole.dns:/etc/dnsmasq.d/'

volumes:
  pihole.vol:
    driver: local
    driver_opts:
      type: "nfs"
      o: addr=192.168.0.13,nolock,soft,rw
      device: ":/media/fdisk/container/pihole2/pihole"
      
  pihole.dns:
    driver: local
    driver_opts:
      type: "nfs"
      o: addr=192.168.0.13,nolock,soft,rw
      device: ":/media/fdisk/container/pihole2/dnsmasq.d"

Don’t forget to mkdir pihole and dnsmasq.d in share directory

Install node-red in docker swarm with share data in nfs


I’m using portainer

Please read my note before this for setting nfs

This is my docker stack ‘

version: "3.7"

services:
  node-red:
    image: nodered/node-red:latest
    environment:
      - TZ=Asia/Jakarta
    ports:
      - "1880:1880"
    networks:
      - node-red-net
    volumes:
      - nodered.vol:/data
    user: root:root

volumes:
  nodered.vol:
    driver: local
    driver_opts:
      type: "nfs"
      o: addr=192.168.0.13,nolock,soft,rw
      device: ":/media/fdisk/nodered/"

networks:
  node-red-net:

If you have permission problem when you running your stack in nfs share maybe you can add user:root:root in your stack it works for me

Happy Coding

Salam Ngoprek

Share nfs volume docker swarm


//Docker stack

version: "3.7"
services:
  web:
    image: nginx
    volumes:
      - nginx.vol:/usr/share/nginx/html
    ports:
      - 80:80
    networks:
      - web

networks:
  web:
    driver: overlay
    name: web

volumes:
  nginx.vol:
    driver: local
    driver_opts:
      type: "nfs"
      o: addr=192.168.0.13,nolock,soft,rw
      device: ":/media/fdisk"


// nfs setting /etc/exports

/media/fdisk *(rw,insecure,sync,no_subtree_check,no_root_squash)


I had problem with nfs share if i use vfat partition, and i change to ext4 for partition usb fdisk and now all volumen working properly (dont forget to change media share to 777 if you have problem to read and write)

Source :

https://pimylifeup.com/raspberry-pi-nfs/

https://sysadmins.co.za/docker-swarm-persistent-storage-with-nfs/

https://linuxize.com/post/how-to-mount-an-nfs-share-in-linux/

https://serverfault.com/questions/212178/chown-on-a-mounted-nfs-partition-gives-operation-not-permitted