Skip to content

Commit 6a1964a

Browse files
committed
Document process attachment for containerized environments
Added instructions for attaching to processes in containers. Signed-off-by: Hao Li <[email protected]>
1 parent ef2a9c6 commit 6a1964a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/attach.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,24 @@ memray detach
126126
:path: detach
127127
:prog: memray
128128
:nodefaultconst:
129+
130+
Attaching to processes running inside containers
131+
------------------------------------------------
132+
133+
When attaching to a process that runs inside a container from the host,
134+
memray's GDB-based injector relies on being able to load the memray helper
135+
library and access the target process's Python symbols inside the target
136+
PID namespace. If memray (and its extension module) is not installed inside
137+
the container, GDB's injection may fail and the target process can crash
138+
(see: https://github.com/bloomberg/memray/issues/846).
139+
140+
To avoid this issue:
141+
142+
Install memray inside the container as well as on the host:
143+
``pip install memray`` (or your preferred installation method) in the
144+
container environment so the injector can find the correct _inject.abi3.so
145+
and interpreter symbols.
146+
147+
Alternatively, run memray directly inside the container (preferred when
148+
possible), e.g. ``docker exec -it <container> memray run ...`` or attach
149+
from within the container.

0 commit comments

Comments
 (0)