A worker reports as root inside its container but cannot set the host clock - why is root inside not root on the host?
answer
- same number, two different meanings
- the id is a label in a view
- the kernel checks the host id
- root's authority is a set, not a switch
- host-wide powers were never granted
basics
~20 sRoot inside a container is an id read in that container's own view, and the runtime already trimmed its privilege set, so host-wide powers like setting the clock are missing. Many setups also map that id onto an unprivileged host id.
solid answer
~40 sThe id a process reports inside the boundary is read against that container's own view of ids; the kernel still decides every real operation using the host id behind it and the privilege set the process actually holds. Three things separate the two. First, the runtime starts the workload with a small default subset of root's individually grantable privileges, so host-wide operations - setting the clock, loading kernel code, changing the host's network configuration - were never handed over. Second, the process sees only its own root filesystem, process table and network view, so there is far less within reach. Third, many setups remap ids, so inside `0` is an ordinary unprivileged host id. Designs differ on that third point, which is why "root inside is harmless" is too strong as a blanket claim.
go deeper
Remember the one-liner and the reason behind it: the id reported inside is read in the container's own view, and the process was started with only part of root's authority. Be able to name two things it still cannot do.
Explain the mechanism in three parts - the trimmed privilege set, the separate views, and id remapping - and say which of the three is actually present in your environment rather than assuming all three.
Show the diagnostic habit: read the denied operation, not the id, and know that ownership appearing on a mounted host directory tells you immediately which arrangement the host is running.
The tradeoff you own is what the platform guarantees to every team by default, and whether an environment where inside-root is host-root is acceptable for shared hosts or is a standard worth changing.
## Two different things are both called "root" A container run quietly overloads the word. One meaning is **the id a process reports inside the boundary**: the number it gets back when it asks who it is, read against that container's own view of ids. The other is **the account that owns the machine**: the id the host kernel recognises when it decides whether this process may open that file, load that code, or change that machine-wide setting. Only the second one is ever enforced. Every permission decision is made against the host id the process actually carries, together with the set of privileges that process holds. The number the process reads back for itself is a label inside a view - useful for the software running there, not the thing being checked. This is why the two symptoms in the question sit side by side without contradiction. The worker really is id 0 as far as everything inside the boundary is concerned. It still cannot set the clock, because setting the clock is not something that id was given the authority to do. ## What the runtime removes before your process starts Root's authority on a machine is not a single switch. It is a set of separately grantable privileges, and a container runtime hands a new workload a small default subset of them. The ones normally withheld are the ones whose effect reaches past the boundary: - loading or unloading kernel code - setting the machine's clock - changing the host's network configuration or its packet-filtering rules - mounting and unmounting filesystems - rebooting the machine or writing kernel tunables - inspecting or tracing processes outside the container's own process table The ones normally kept are the ones whose effect ends at the boundary: changing ownership and modes on files inside the container's own root filesystem, signalling its own processes, binding ordinary ports, creating users that only exist in its own view. The rule worth carrying is that shape, not the list: **a privilege that would change something shared with the host is withheld; a privilege whose blast radius ends inside the container is kept.** There is one clock for the whole machine and one kernel for the whole machine. Neither is fenced per container, so neither can be handed to a workload without handing it the host. ## The three separations, side by side | What separates inside-root from host-root | What it does | What it does not do | |---|---|---| | The trimmed privilege set | Removes the host-wide operations from the process before it starts | Does not change which host id the process runs as | | Separate views of filesystem, process table and network | Shrinks what is reachable at all | Does not reduce authority over what remains reachable | | Id remapping | Translates inside ids onto unprivileged host ids | Is not switched on in every setup | The three are independent. A workload can have a trimmed privilege set and no remapping, or remapping and a generous privilege set. Knowing which of the three is doing the work in your environment is the difference between a model and a slogan. ## Where remapping fits, and why designs differ In one common arrangement the runtime itself is a privileged host service, and the container's id 0 is the host's id 0 - literally the same account, restrained by the trimmed privilege set, by the separate views, and by whatever confinement profile is applied. A file that process writes onto a host directory mounted into the container is owned by the host's root account. In the other arrangement, usually called **rootless**, the whole runtime is started by an ordinary unprivileged operator, and every id inside the container is mapped onto a range of unprivileged host ids that the operator is permitted to use. Inside id 0 becomes some high, unremarkable host id. That mapping is exactly what lets an unprivileged operator run a root-looking process at all: the process is root over the container's own view and over nothing else. So "root inside is not root outside" is true in both arrangements, but for different amounts of reason. The strongest version of the claim - that the inside-root process is just an ordinary unprivileged host user - only holds where remapping is on. Find out which arrangement you are in before you lean on it. ## What follows in practice 1. When a process that reports id 0 is refused an operation, read the **operation**, not the id. A refusal on setting the clock or loading kernel code is a withheld privilege, not a wrong file mode. 2. Whether inside-root is host-root decides what ownership appears on a host directory mounted into the container. That is the surprise teams hit first when they move between the two arrangements. 3. None of this makes running as inside-root a good posture. It explains why it is not automatically a disaster; the argument for running as an ordinary unprivileged account regardless is a separate, and stronger, one.
- Which of root's powers does a container workload usually keep, and why those?The ones whose effect ends at the boundary: changing ownership and modes inside its own root filesystem, signalling processes in its own process table, binding ordinary ports, adding users that exist only in its own view. Each of those acts on something the container already has its own copy of, so granting it cannot reach another workload or the host.
- If id remapping is switched off, is inside-root then the same as host-root?As an identity, yes - the kernel sees the host's root account. As authority, no: the process still holds only the trimmed privilege set and still sees only its own filesystem, process table and network view. The practical difference shows up on shared surfaces, where files it creates on a mounted host directory are owned by host root.
- A process that reports id 0 inside is refused an operation. What should you read first?The operation. If it is host-wide - clock, kernel code, host network configuration, mounting - a privilege was withheld deliberately, and the fix is either to grant that one privilege or to move the work out of the container. If it is a read or write on a mounted host path, it is an ownership and id-mapping problem instead, and no privilege change will help.
A visitor badge can say DIRECTOR and open every door on one floor. The building's own systems still know which real record that badge maps to, and the plant room was never on its list.
saying these in an interview costs you the question
- Thinks id 0 inside a container always means full authority on the host
- Assumes the kernel makes its permission decision using the id reported inside
- Believes every container setup remaps inside root onto an unprivileged host id
- Treats root's authority as one switch rather than a set of separate privileges
- Thinks the clock is fenced per container the way the filesystem view is
- Calls a refusal on a host-wide operation a bug in the image