Correct permissions for shared folder?

I’m sharing a host folder with my Ubuntu 24.04 container:

lxc config device add my_container device_name disk source=~/my-code path=/home/ubuntu/my-code

In an attempt to give container user ubuntu (id=1000) permissions on the folder, I’m running this on the host sudo chown -R 101000:101000 ~/my-code

However, files in the container don’t belong to anyone nobody:nogroup. How do I adjust permissions so container user ubuntu can edit the files?

This is a UID/GID mapping issue, not a regular permissions problem.

In an unprivileged LXC container, the user ubuntu (UID 1000) is mapped to a different UID on the host (often 101000). If the ownership on the host doesn’t match that mapping, files show up as nobody:nogroup in the container.

You can either:

Option 1 – Let LXC handle the mapping automatically (recommended):

lxc config device add my_container my-code disk \
  source=/home/youruser/my-code \
  path=/home/ubuntu/my-code \
  shift=true

Option 2 – Verify and match the mapped UID manually:

cat /proc/self/uid_map   # run inside the container
sudo chown -R 101000:101000 ~/my-code

After adjusting, restart the container:

lxc restart my_container

That should allow the ubuntu user inside the container to edit the files normally.

I was missing one zero! sudo chown -R 1001000:1001000 ~/my-code worked. And thank you for the shift=true tip.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.