Docker NFS Mount Permission Issues on Raspberry Pi

Problem Description

Attempting to access an SSD connected to Raspberry Pi 1 running an NFS service, permission issues were encountered when trying to run a Docker container on Raspberry Pi 2.

Troubleshooting Steps

  1. Check Ownership and Permissions on NFS Server (rp1): Verify that the export directory /home/shashank/ssd has the correct ownership and permissions:

    ls -ld /home/shashank/ssd
  2. Update Ownership: If necessary, change the ownership to the user that runs the Docker daemon on rp2:

    sudo chown -R root:root /home/shashank/ssd
  3. Inspect Docker Networks: List all Docker networks available on rp2 and inspect the default bridge network to obtain the IP address range:

    sudo docker network ls
    sudo docker network inspect bridge
  4. Update NFS Exports Configuration: Modify the /etc/exports file on the NFS server (rp1) to allow the Docker network range access:

    sudo nano /etc/exports
    /home/shashank/ssd <docker-network-range>(rw,sync,no_subtree_check,no_root_squash)

    Apply the settings and restart the NFS server:

    sudo exportfs -ra
    sudo systemctl restart nfs-kernel-server
  5. Run Docker with Privileged Flag if Necessary: Use the --privileged flag to give extended privileges to a Docker container, allowing it to perform actions like mounting file systems which are normally restricted:

    sudo docker run -it --rm --privileged --user=root alpine /bin/sh