$ docker run --privileged --pid=host -it alpine:3.8 \
nsenter -t 1 -m -u -n -i sh
--rm
: removes the container after it is stopped-ti
(or-t -i
) : adds a tty and leaves the standard input opened--privileged
: grants additional permissions to the container, it allows the container to gain access to the devices of the host (/dev)--pid=host
: use the host's Process ID Namespace. Allows the container to use the process tree of the Docker host (the machine in which the Docker daemon is running)
nsenter
-t
PID Target process to get namespaces from-m
Enter mount namespace-u
Enter UTS namespace (hostname etc)-i
Enter System V IPC namespace-n
Enter network namespace-p
Enter pid namespace