Safely sharing host directory amongst multiple LXC containers

johnha

Well-Known Member
Jan 1, 2018
34
5
48
A quick validation question for the gurus here:

Is it possible to bind mount a host directory to multiple LXC containers and not run into disk write conflicts?

Let's say there is a folder [or entire drive] on the host at /mnt/ssd/myfolder. And I have multiple unprivileged LXC containers, say 101, 102, 103, etc. for which I have the following in their configuration files: mp0: /mnt/ssd/myfolder/,mp=/mnt/sharedfolder. (Let's assume that I've mapped all the GID/UIDs properly so that these unprivileged containers have proper write access to the shared folder on the host.)

Is this safe?

I only ask because of some bad memories when I was first starting with PVE and I had some disk conflicts because I had multiple CTs writing to a host directory and causing data corruption.

Also, would it still be safe if I used this line in the config files[1] for 101, 102, 103, etc.:
lxc.mount.entry: /mnt/host/directory /mnt/guest/directory none bind 0 0

Is this also safe?

[1] Found at: https://forum.proxmox.com/threads/why-do-bind-mounts-prevent-snapshots.85495/

Many thanks in advance!
 
I only ask because of some bad memories when I was first starting with PVE and I had some disk conflicts because I had multiple CTs writing to a host directory and causing data corruption.
Are you sure you were bind-mounting folders into LXCs and not mounting block devices into VMs/LXCs?
 
Are you sure you were bind-mounting folders into LXCs and not mounting block devices into VMs/LXCs?

It must have been something like that.. I can't remember the exact configuration. But it was bad enough that I want a bit of reassurance that bind mounts can be rw mounted on multiple containers without conflict :)
 

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!