Interview Prep/Docker/Containers, VMs & Isolation Internals

How do you see which namespaces a container uses and enter them from the host?

IntermediateConceptContainers, VMs & Isolation Internals
Answer

Find the PID and use nsenter, which is essentially what docker exec does conceptually.

PID=$(docker inspect -f '{{.State.Pid}}' web)
sudo nsenter -t $PID -n ip addr      # network namespace only
sudo nsenter -t $PID -m -u -i -n -p sh   # mount, uts, ipc, net, pid

Handy when the image has no shell or no ip binary.

All Docker questions Roadmap: Docker & containers

More on Containers, VMs & Isolation Internals