Hi everyone.
I’m trying to mount a directory from the host into a container, and give root read and write permissions in that. I found that using the disk
device with the shift=true
option seems to be exactly what I need.
I’ve tested this from the root user on the host, and it’s working well.
root@MyPC:~# ls -lh
total 4.0K
drwxr-xr-x 2 root root 4.0K Jul 23 13:30 testdir
root@MyPC:~# incus launch images:alpine/3.20 ctner-root
Launching ctner-root
root@MyPC:~# incus config device add ctner-root test-vol disk source=/root/testdir path=/testdir shift=true
Device test-vol added to ctner-root
However, when I switch to a normal user (in group incus
, of course), the same command doesn’t work.
[~]$ ls -lh
total 4.0K
drwxrwxr-x 2 me me 4.0K Jul 23 13:44 testdir
[~]$ incus launch images:alpine/3.20 ctner-user
Launching ctner-user
[~]$ incus config device add ctner-user test-vol disk source=/home/me/testdir path=/testdir shift=true
Error: Failed to start device "test-vol": The "shift" property cannot be used with a restricted source path
I did some search and found that this message might be related to the restricted project. But it looks like I’m launching a single container directly. Or am I missing something?
- https://discuss.linuxcontainers.org/t/weekly-status-225/12700
- https://github.com/canonical/lxd/security/advisories/GHSA-x9qq-236j-gj97
Could you please let me know what’s causing this issue? Any ideas on how I can get around this?
Just to give you a heads-up, my OS environment is:
- OS: Debian Trixie (Testing) amd64
- Incus: version 6.0.1
Please bear with me as I’m trying to find a way to mount the directory that might be as simple as docker’s -v
, without a lot of extra configuration. So I would prefer not to go down the route of changing the /etc/subuid
and /etc/subgid
like most posts usually do if I can get the shift
option to do the trick instead. Please also let me know if I’ve got any key information wrong.
Thanks in advance!