gdb in docker container returns quot;ptrace: Operation not permitted.quot;(docker 容器中的 gdb 返回“ptrace:不允许操作.)
问题描述
我在容器和主机上检查了 /proc/sys/kernel/yama/ptrace_scope
- 两者都将值报告为零,但当附加到 pid 时,一个 gdb 报告
I've checked /proc/sys/kernel/yama/ptrace_scope
in the container and on the host - both report the value as zero but when attached to pid one gdb reports
Reading symbols from /opt/my-web-proxy/bin/my-web-proxy...done.
Attaching to program: /opt/my-web-proxy/bin/my-web-proxy, process 1
ptrace: Operation not permitted.
我也尝试过使用特权标志附加到容器
I've also tried attached to the container with the privileged flag
docker exec --privileged -it mywebproxy_my-proxy_1 /bin/bash
主机操作系统是 Fedora 25,带有来自其 repos 的 docker,容器是官方的 centos6.8
Host OS is Fedora 25 with docker from their repos and container is a official centos6.8
推荐答案
我找到了答案——容器需要启动strace能力
I discovered the answer - the container needs to be started with strace capabilities
将它添加到我的 docker-compose.yml 文件允许 GDB 工作
Adding this to my docker-compose.yml file allows GDB to work
cap_add:
- SYS_PTRACE
或者也可以在docker命令行中使用--cap-add=SYS_PTRACE
Or it can also be passed on the docker command line with --cap-add=SYS_PTRACE
这篇关于docker 容器中的 gdb 返回“ptrace:不允许操作".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:docker 容器中的 gdb 返回“ptrace:不允许操作".


- Stroustrup 的 Simple_window.h 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- C++ 协变模板 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 近似搜索的工作原理 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 从python回调到c++的选项 2022-11-16