0

when I am mount volume in docker with root user like this:

# mount -t nfsxxxx-pli55.cn-shanghai.nas.aliyuncs.com:/k8s/reddwarf-pro/chat-server-service /home/nfs/
mount: /home/nfs: permission denied.

shows permission denied, then I tried to use this command:

chmod -R 777 /home/nfs

and rerun the bind command, still shows that the permission denied. why did this happen? what should I do to fixed this issue? why could not use the mount command with root user?

spark
  • 663
  • 1
  • 5
  • 18
  • 2
    You can't normally mount filesystems inside a Docker container, whether from a debug shell or anywhere else. Can you mount the filesystem somewhere else, maybe as a named volume, and attach it to the container at startup time? – David Maze Apr 09 '23 at 11:14
  • 1
    [Mount SMB/CIFS share within a Docker container](https://stackoverflow.com/questions/27989751/mount-smb-cifs-share-within-a-docker-container) discusses the Linux capability restriction that's causing the error. [Mounting nfs shares inside docker container](https://stackoverflow.com/questions/39922161/mounting-nfs-shares-inside-docker-container) describes a pure-Docker workflow in its [accepted answer](/a/45911186). – David Maze Apr 09 '23 at 11:17
  • I created a nfs pv and pvc and I want to test the mount command. – spark Apr 09 '23 at 11:47
  • 1
    If this is in a Kubernetes context, the previous links won't work for you. Mount the PersistentVolumeClaim in your Deployment spec. Don't try to do things (and especially administration-type commands) in `kubectl exec` shells: in Kubernetes especially, they'll only affect one replica of your Deployment, and it's possible for the cluster to automatically delete a Pod in some circumstances and your changes will be lost. – David Maze Apr 09 '23 at 11:53

0 Answers0