Folder sharing host/container

No expert in id mapping, but i guess the solution must lay somewhere in that area.

I setup a couple of containers, and they should behave as VM’s, in a sense that every user get his/her own useraccount.
There is a fodler on the host that holds data that I would like to use in the share.

So every container user should be able to read and write in that host folder. I’m not really concerned about owner rights whitin that folder, as long as that folder is isolated.

The folder on the host is now owned by a specific user (let’s call him host_user).
the users in the container are LDAP (active directory users).
I added the folder using add device.

I should somehow be able to either run the container as the user owing the folder or map all possible users ot that specific host_user.

Any help?

(BTW If this is a stupid setup please let me know!)

here is how I did it:

1 start the container, then do:

sudo ls -la /var/lib/lxd/storage-pools/default/containers/local-mail

there I got the ID, 100000

2 change the folder in the host to 100000:

sudo chown 100000.100000 local-mails-home/

  1. attach the device:

sudo lxc config device add local-mail lxdshare disk source=/mypool/local-mails-home path=/home

now I can create users inside the container and all goes into the local-mails-home folder

it works so far, not sure if that’s a good solution