Issues with lxc bind mount

Por12

New Member
Mar 6, 2023
28
2
3
Hi there,

I have been trying for a couple days to give bind mounts to an unprivileged LXC. I'd like to have write access to an NFS share mounted on the host on /mnt/pve/paperless.

On first instance I had write access using:

Code:
lxc.idmap: u 0 0 1
lxc.idmap: u 1 100000 65535
lxc.idmap: g 0 0 1
lxc.idmap: g 1 100000 65535

However, I'd like to map the uid/guid 1005 in the container so that I can map my paperless instance to that user and everything works fine. To do that, I've changed my lxc.conf to map that uid/guid as the wiki explains:

Code:
memory: 4096
mp0: /virtualization_hosts/docker_data,mp=/docker
mp1: /mnt/pve/paperless,mp=/paperless-storage,replicate=0
net0: name=eth0,bridge=vmbr0,hwaddr=32:D2:40:13:7C:16,ip=dhcp,type=veth
onboot: 1
ostype: debian
rootfs: local:501/vm-501-disk-0.raw,size=16G
swap: 512
tags: proxmox-helper-scripts
unprivileged: 1
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

I've added:

Code:
echo "root:1005:1" >> /etc/subuid
echo "root:1005:1" >> /etc/subgid

And run chmod -R 1005:1005 /virtualization-hosts/docker

However, there seems to be something wrong as when I SSH into the container I get the following error: /root/.bashrc: Permission denied. I cannot run docker compose as I get:

Error loading config file: /root/.docker/config.json: open /root/.docker/config.json: permission denied

If I run: ls -lhn /docker/ all seems to be correctly mapped:

Code:
drwx------ 3 1005 1005   3 Oct  5 12:09 config
-rw-r--r-- 1 1005 1005 172 Oct 10 23:42 docker-compose.yml
drwx------ 2 1005 1005   2 Oct  5 12:09 images
drwx------ 8 1005 1005  10 Oct 11 12:48 paperless
drwx------ 3 1005 1005   4 Oct  5 17:56 portainer
drwx------ 3 1005 1005   3 Oct  5 12:09 runtime
drwx------ 2 1005 1005   2 Oct  5 12:09 scripts
drwx------ 2 1005 1005   2 Oct  5 12:09 secrets
drwx------ 3 1005 1005   5 Oct 10 23:42 traefikv2


What am I missing? If I go back to the first mapping all works fine.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!