Share files between LXC containers

grobs

Active Member
Apr 1, 2016
56
0
26
38
France
Hi everyone,

Short question: What is the best way to share files between several LXC containers?

I have a Proxmox 4 cluster and a Proxmox5 (ZFS storage) cluster.
In both of them, I would like to create a shared filesystem (NFS, ZFS or whatever...) and mount it into several LXC containers in order to read and write files on this shared filesystem.

I found some wiki pages and forum posts that are about this but I'm still a bit confused with the best way to do this.

Regards
 
Technically, you want to share a folder, not a filesystem, which is not as easy as it sounds. On a file level, there are several tools available, that work via network e.g. NFS, SAMBA/CIFS. If you have ZFS on your PVE, you can just bind-mount directories into your container, but be aware, you cannot snapshot them anymore with bind-mounts

So, the "best way " (to have all features, yet use a kind of shared filesystem) is to have the data external and mount it in via NFS/CIFS. This setup is more complicated and needs probably more permissions on the LXC side, yet you can still snapshot everything.
 
Problem with NFS/SMB shares inside LXCs is that this is only allow for the more unsecure privileged LXCs (and you need to enable the NFS/CIFS feature first).