Part 5 of 7 · 2 min read
Inspecting a container
Think of a detective checking which rooms in a building belong to which tenant, using the register at the front desk. Each room's entry gives the tenant and the lease number. The analogy stops in one place: a register can be wrong, while the kernel's own numbers cannot.
In plain words: From the host, an administrator can see and check a container with ordinary tools. The container's process is an entry in the host's process list. Its namespace links in /proc/PID/ns show which namespaces it shares with the host. Its group is in /proc/PID/cgroup. The network and mounts are in /proc/PID/net and /proc/PID/mountinfo. nsenter runs a command inside.
A worked example. The five namespace links, read inside the container and then on the host:
Inside the container On the host
mnt:[4026532264] mnt:[4026531832]
net:[4026532267] net:[4026531833]
pid:[4026532266] pid:[4026531836]
user:[4026531837] user:[4026531837]
uts:[4026532265] uts:[4026531838]
Four numbers differ: mount, network, PID and UTS, the four flags that the launcher passed. The user namespace is equal: the container's root is the host's real root (user ID 0), limited only by what the launcher drops. This is the gap that Level 10 pointed to, and the reason to add a user namespace, dropped capabilities and a seccomp filter in a real tool.
The key lines. An inspection takes a few commands and shows exactly what a container is separated from. Always check the user namespace line: an equal number means that root inside is root outside.
Whiteout
A whiteout is a marker in the writable layer of an overlay file system that hides a file from a lower layer. It is stored as a special character device with numbers 0, 0 under the file's name.
Example: deleting base.txt in the overlay left a character device base.txt in the upper directory, and the lower file stayed.
Check yourself: 1. Which namespaces did the launcher not create? 2. What does an equal user namespace number mean for the container's root? 3. How can an administrator run a command inside a running container?