Namespaces

from chroot() to containers

Iustin Pop, iustin@k1024.org

March 30th, 2019

About

In the beginning…

chroot()

problems with chroot()

Other attempts

FreeBSD jails

FreeBSD jails - basics

FreeBSD jails - limitations

OpenVZ - first attempt at Linux containers

Linux namespaces

hello virtualisation

local resources

global resources

interlude: capabilities

boring namespaces

Cgroup namespace

Mount namespace

Net namespace #1

Net namespace #2

# ip -o l
1: lo: …
2: eth0: …
# unshare --net
# ip -o l
1: lo: …
#
# ip link add veth2-left type veth peer veth2-right
# ip link set veth2-right netns ns-right

PID namespaces

PID namespaces #2 - peculiarities

PID namespaces #3 - everybody can be init!

Finally, the magical user namespace

why is this special?

test@debian:~$ id
uid=1001(test) gid=1001(test) groups=1001(test)
test@debian:~$ unshare --user
nobody@debian:~$ id; exit
uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
test@debian:~$ unshare --user --map-root-user
root@debian:~# id
uid=0(root) gid=0(root) groups=0(root)

so what? fake root, right?

test@debian:~$ unshare --user --map-root-user --mount
root@debian:~# df -h|grep /mnt
root@debian:~# mount -t tmpfs none /mnt/
root@debian:~# df -h|grep /mnt
none            998M     0  998M   0% /mnt

how much root?

more details

processes and namespaces

user and group IDs

user and group ID mappings

user and group ID mappings #2

Conclusion

Did not talk about…

Power, but…

Resources

Thanks!