I cannot get my head around the userns-idmap mapping ie with sub{uid,gid} mapping stuff.
Here's what I have:
# lxc launch images:ubuntu/22.04 c1
# lxc config device add c1 home disk source=/home/user3/ path=/home/user3
# lxc config device add c1 shared disk source=/mnt/shared path=/mnt/shared
Then I added a user and group to the container:
# lxc exec c1 bash
# groupadd -g 1003 user3
# groupadd -g 1004 shared
# useradd -u 1003 -g 1003 -G shared user3
- The user
user3
has the uid1003
on the host and belongs to the groupshared
(as well as its own) - The group
shared
has the gid of1004
Here's my sub{uid,gid}
:
sudo tee /etc/sub{uid,gid} <<EOF
root:1000:65536
user0:100000:65536
user1:100001:65536
user2:100002:65536
user3:100003:65536
EOF
sudo tee -a /etc/subgid <<EOF
shared:100004:1
EOF
I want to map user3
's uid 1003
and gid 1003
into the container. I also want to map shared
which is 1004
on the host into the container.
- Is my
/etc/sub{uid,gid}
correct? - What do i need for the
raw.idmap
command? - I want to make a
c2
container which has home directories foruser0-3
mapped through.
I tried:
# printf 'both 1003 1003\ngid 1004 1\n' | lxc config set c1 raw.lxc -
to begin with, but was getting the error:
ERROR conf - ../src/lxc/conf.c:lxc_map_ids:3672 - newuidmap failed to write mapping "newuidmap: uid range [1001-1002) -> [100003-100004) not allowed": newuidmap 22185 0 1000 1001 1001 10000
ERROR start - ../src/lxc/start.c:lxc_spawn:1791 - Failed to set up id mapping.