Docker privileged container escape

docker run --privileged --pid=host -it alpine nsenter -t 1 -m -u -i -n -p sh

Escape from a privileged container: with --privileged and --pid=host, nsenter enters the namespaces of the host's PID 1 and gives you a shell with host system privileges.

When you are inside a container launched with --privileged (all capabilities, no seccomp) or have access to docker to launch one yourself. --pid=host allows seeing host processes; nsenter -t 1 enters its namespaces (mount, uts, ipc, net, pid) and lets you operate as if you were on the host.

If the container is not privileged and you lack CAP_SYS_ADMIN, nsenter will fail with permission denied. Also not if the host uses user namespaces (userns-remap in the daemon): the container's UID 0 is not the host's.