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:不允许操作".
基础教程推荐
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- c++ STL设置差异 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
