Hi all,
how can we mount a folder from the host to the container rw mode? in a way i dont have to change user id’s and stuff like that?
Hi all,
how can we mount a folder from the host to the container rw mode? in a way i dont have to change user id’s and stuff like that?
I had the same problem.
The solution is shiftfs:
modinfo shiftfs
1.a) If your kernel does not include it, you can use dkms to install shiftfs:
I created a github repo with scripts to install shiftfs via dkms:
- sudo snap set lxd shiftfs.enable=true
- sudo systemctl reload snap.lxd.daemon
Check whether it is activated:
- lxc info
And should see:
shiftfs: "true"
folder1: path: /home/user1/folder1 source: /home/hostuser1/folder1 shift: true type: disk
And it should work.
Edit: Added my github repo.
Also interesting:
But maybe that is only for virtual machines (?).
Yeah, that’s for VM.
For containers the disk devices work fine but you indeed either need shiftfs or need to add some ACLs to allow write access.
How to add acls? Is this different then changing ids?
Yeah, it makes it possible for a container and the host to both have access.
You’d usually keep the ownership on the host as it is, then use setfacl to allow access by particular user or groups from inside the container.
Do i need to do this in the container or on the host. Because in the container root can not create files or setfacl
allredeay got it i think.
I need to do it with ids otherwise it is not working (by usernames). Is the disk mounted auto after reboot?
For everyone who is interested in using shiftfs, here is my github repo for shiftfs via dkms: