docker 容器中的 gdb 返回“ptrace:不允许操作". [英] gdb in docker container returns "ptrace: Operation not permitted."

查看:38
本文介绍了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:不允许操作".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆