4

I have configured for namespaces for unprivileged LXC containers using this docuement

https://help.ubuntu.com/lts/serverguide/lxc.html#lxc-unpriv

I can create and start containers using lxc-create and lxc-start without using sudo.

But now I want to modify the container before starting it, but I cannot do it because rootfs is owned by user 100000:

vagrant@lxci-host:~$ ls -l $HOME/.local/share/lxc/u1/ total 8 -rw-rw-r-- 1 vagrant vagrant 616 Nov 22 12:38 config drwxr-xr-x 21 100000 100000 4096 Nov 22 12:38 rootfs

How can I workaround this?

The container was created using this

lxc-create -t download -n u1 -- -d ubuntu -r trusty -a amd64

1 Answer 1

5

Got it. By using lxc-usernsexec command to execute my container modifying commands.

Man page quote:

NAME
       lxc-usernsexec - Run a task as root in a new user namespace.

SYNOPSIS
       lxc-usernsexec [-m uid-map] {-- command}

DESCRIPTION
       lxc-usernsexec can be used to run a task as root in a new user namespace.

Example for custom /etc/hosts file

lxc-usernsexec cp hosts $HOME/.local/share/lxc/u1/rootfs/etc/hosts
1
  • Cool. I built a whole /etc/subuid parser exactly for this purpose... Mar 12, 2015 at 6:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .