Conversation

Jarkko Sakkinen

Edited 5 days ago

my #build #container framework:

sudo unshare \
  --fork \
  --mount \
  --uts \
  sh -c "
    mkdir -p $ROOTFS/proc
    mkdir -p $ROOTFS/sys
    mkdir -p $ROOTFS/dev
    mount -t sysfs /sys $ROOTFS/sys
    mount -t proc /proc $ROOTFS/proc
    mount --rbind /dev $ROOTFS/dev
    hostname $MACHINE
    su $USER
    export PUAVO_CACHE_PROXY=$PUAVO_CACHE_PROXY
    sudo unshare --root $ROOTFS $CMDLINE
  "

Nests nicely with #Docker and #Podman :-)

1
0
1

@jarkko
Could you explain it ?
In particular, I'm having trouble understanding this part:
sudo unshare \
sh -c "
sudo unshare --root $ROOTFS $CMDLINE
"

1
0
0
@slamp Absolutely not because this is not a code review ;-) I'd suggest to refer to man7.org instead.

However, the gist with two nested unshares is that I can guarantee unmounts of the binds even in the case of CPU exception.
0
0
0