Join another container's mount namespace on Linux

Hi! I have been using gdb in its own container to debug my C++ apps in other containers using:

docker run --cap-add=SYS_PTRACE --pid="container:4ebef7e35562" -it centos:centos7 bash

But I discovered that --pid="container:id only joins the PID namespace, not the mount namespace.

I’d like to do something like:

docker run --cap-add=SYS_PTRACE --mnt="container:4ebef7e35562" --pid="container:4ebef7e35562" -it centos:centos7 bash

Where --mnt="container:id tells my gdb container to join the other container mount namespace.

Is there a way for a container to join another container’s mount namespace?

1 Like