Sharing a host's folder with containers for read and write

eugrus

New Member
Aug 2, 2022
16
2
3
I am currently running into permission errors inside an Alpine LXC (using the template included with Proxmox 7.3) when trying (as root) to mount a folder shared on the Proxmox host.

The error occurs for both SMB and NFS.

Here is how it looks like from the client side:
Code:
Alpine-CT100:~# cat /etc/fstab
/dev/cdrom      /media/cdrom    iso9660 noauto,ro 0 0
/dev/usbdisk    /media/usb      vfat    noauto,ro 0 0
192.168.10.2:/storage   /nfs/storage    nfs     auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
//192.168.10.2/Storage  /mnt/storage    cifs    guest,uid=1000,iocharset=utf8  0  0
Alpine-CT100:~# mount -a
mount.nfs: Operation not permitted
mount: mounting 192.168.10.2:/storage on /nfs/storage failed: Invalid argument
mount error(1): Operation not permitted
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
mount: permission denied (are you root?)
Alpine-CT100:~#

And here are the configs on the server side:
Code:
root@mr:~# cat /etc/exports
/storage        192.168.10.0/255.255.255.0(rw,sync,no_root_squash,no_subtree_check)

root@mr:~# cat /etc/samba/smb.conf

[global]

   workgroup = WORKGROUP

   interfaces = 192.168.10.0/24 eth0


   log file = /var/log/samba/log.%m

   max log size = 1000

   logging = file

   panic action = /usr/share/samba/panic-action %d

   server role = standalone server

   obey pam restrictions = yes

   unix password sync = yes

   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

   usershare allow guests = yes

[homes]
   comment = Home Directories
   browseable = no

   read only = yes

   create mask = 0700

   directory mask = 0700

authentication schemes
   valid users = %S

[Storage]
  comment = Storage share folder
  path = /storage
  browseable = yes
  read only = no
  guest ok = yes

Total Commander and VLC on my Android phone are accessing that SMB share just fine btw.
 
Last edited:
Tried in a Ubuntu-container with basically the same result:

Code:
root@Ubuntu-CT101:~# cat /etc/fstab
192.168.10.2:/storage   /nfs/storage    nfs     auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
//192.168.10.2/Storage  /mnt/storage    cifs    guest,uid=1000,iocharset=utf8  0  0
root@Ubuntu-CT101:~# mount -a
mount: /nfs/storage: permission denied.
mount: /mnt/storage: permission denied.
 
I am starting to understand, that this is supposed to be a feature, not a bug.

However, what is the de lege artis way to share a host's folder with some containers and give those containers RW access to it? I don't like the idea of creating the shared folder itself inside a containerized image instead.
 
Last edited:
so did it work ? -- i am unable to read or write on the drive shared from host to container
In case you didn't find it, and for anyone else who finds this from Google, the answer is on the link provided above (https://pve.proxmox.com/wiki/Linux_Container#pct_settings) but you have to scroll down to Bind Mount Points where it says:

Bind mounts allow you to access arbitrary directories from your Proxmox VE host inside a container. Some potential use cases are:
- Accessing your home directory in the guest
- Accessing an USB device directory in the guest
- Accessing an NFS mount from the host in the guest
...
For example, to make the directory /mnt/bindmounts/shared accessible in the container with ID 100 under the path /shared, add a configuration line such as:
mp0: /mnt/bindmounts/shared,mp=/shared
into /etc/pve/lxc/100.conf.

Or alternatively use the pct tool (in the Host node's >_Shell):
pct set 100 -mp0 /mnt/bindmounts/shared,mp=/shared

I used this as template to share my SMB/CIFS from my host mounted at /mnt/pve/<name-of-storage> to /mnt/data in the container with ID 100 using the following:
pct set 100 -mp0 /mnt/pve/<name-of-storage>,mp=/mnt/shared

Hope this helps!
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!