Share folder between containers

Hey there,

hopefully i am not bothering anyone with all my questions in the last few days but surprisingly i got another one today. :slight_smile:

Does LXD support sharing folders between containers?
Use case is that nginx that acts as a reverse proxy needs access to a folder that is located inside another container. I assume i could do this with samba but maybe i can do this with lxd directly?
When i did some research i could only find a way to do this from the host machine to a container but not between containers.

As always, thank you for taking the time.

The recommended way to handle this is by creating a custom storage volume with lxc storage volume create and then attach it to both containers at the relevant path.

Something like:

  • lxc storage create default blah
  • lxc config device add c1 blah disk pool=default source=blah path=/blah
  • lxc config device add c2 blah disk pool=default source=blah path=/blah

Thank you Stéphane, very helpful.
I created a new zfs volume inside the custom dataset with lxc storage volume create and attached it to my container configuration files.

Just for “ease of mind”, is this more or less experimental or is sharing a zfs volume among containers like i just did, totally legit and can considered to be stable?

No conflicts when both containers try to write to the same zfs volume at the same time.
Should i rather mount them read only in my other containers. (if thats an option)

Thank you very much.

That’s a stable feature that I’ve been using in production systems for over a year now.

Thank you very much Stéphane. :slight_smile: