$ 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
- -tPID Target process to get namespaces from
- -mEnter mount namespace
- -uEnter UTS namespace (hostname etc)
- -iEnter System V IPC namespace
- -nEnter network namespace
- -pEnter pid namespace