I am now struggling a couple of days with this topic and all I tried didn't work so far.
Use case (for info)
I have a docker-container, setup with docker-compose in an unprivileged lxc. The container istself runs without problems and works as espected.
It is about paperlss-ngx which is a system for paperless document management.
paperless-ngx consumes files like pdfs out of a"consume" folder and works on them.
The idea ist to use a smb share as that "consume" folder, because scanners are able to scan directly into a smb share.
Preparation
I added a SMB share (which is set on a physically different NAS with OpenMediaVault) to PVE Host and then bind-mount this share into the lxc with
Now this is the point where the problems start and I understand the point, that uids and gids are mapped between pve host and lxc containers for security reasons and therefore there will be permission issues in default config.
Being root in the lxc (which is unprivileged user 100000 in pve) I am not able to write into that bin-mount.
I went through this article https://pve.proxmox.com/wiki/Unprivileged_LXC_containers but didnt get it to work.
What I did:
I put this into /etc/pve/lxc/<lxc-id>.conf:
In /etc/subuid and /etc/subgid of the lxc I set
respectively.
Then in the pve host I did
but ls -la still shows root:root with 0:0
I then started the lxc, but this fails. I tried within the cli as recommendend, the output is:
I am not shure, mybe I still didnt get one important point on this, or something else is wrong. I do not really understand this problem or the reason, why this fails.
Maybe someone could give a hint into a direction.
Use case (for info)
I have a docker-container, setup with docker-compose in an unprivileged lxc. The container istself runs without problems and works as espected.
It is about paperlss-ngx which is a system for paperless document management.
paperless-ngx consumes files like pdfs out of a"consume" folder and works on them.
The idea ist to use a smb share as that "consume" folder, because scanners are able to scan directly into a smb share.
Preparation
I added a SMB share (which is set on a physically different NAS with OpenMediaVault) to PVE Host and then bind-mount this share into the lxc with
Code:
pct set 105 -mp0 /mnt/pve/smb-share,mp=/mnt/smb-share-lxc
Now this is the point where the problems start and I understand the point, that uids and gids are mapped between pve host and lxc containers for security reasons and therefore there will be permission issues in default config.
Being root in the lxc (which is unprivileged user 100000 in pve) I am not able to write into that bin-mount.
I went through this article https://pve.proxmox.com/wiki/Unprivileged_LXC_containers but didnt get it to work.
What I did:
I put this into /etc/pve/lxc/<lxc-id>.conf:
Code:
lxc.idmap = u 0 100000 1005
lxc.idmap = g 0 100000 1005
lxc.idmap = u 1005 1005 1
lxc.idmap = g 1005 1005 1
lxc.idmap = u 1006 101006 64530
lxc.idmap = g 1006 101006 64530
In /etc/subuid and /etc/subgid of the lxc I set
Code:
root:1005:1
Then in the pve host I did
Code:
chown -R 1005:1005 /mnt/pve/<smb-share>
I then started the lxc, but this fails. I tried within the cli as recommendend, the output is:
Code:
root@pve:~# lxc-start -F -n 105
lxc-start: 105: conf.c: lxc_map_ids: 3663 newuidmap failed to write mapping "newuidmap: uid range [1005-1006) -> [1005-1006) not allowed": newuidmap 166147 0 100000 1005 1005 1005 1 1006 101006 64530
lxc-start: 105: start.c: lxc_spawn: 1785 Failed to set up id mapping.
lxc-start: 105: start.c: __lxc_start: 2068 Failed to spawn container "105"
lxc-start: 105: tools/lxc_start.c: main: 306 The container failed to start
I am not shure, mybe I still didnt get one important point on this, or something else is wrong. I do not really understand this problem or the reason, why this fails.
Maybe someone could give a hint into a direction.