Run gdb inside docker container running systemd

我们两清 提交于 2019-12-11 08:29:03

问题


I was able to start a docker container running systemd using

sudo docker run -it -p 8022:22 -e container=docker debug-image /sbin/init

However, gdb was not able to debug C processes in this environment, because it lacked the required SYS_PTRACE capability.

I tried adding --cap-add=SYS_PTRACE to the docker run command line, but then systemd appeared to hang on startup (it printed nothing to the terminal). The same thing happened when I tried passing --privileged instead.


回答1:


This command worked:

sudo docker run -it -p 8022:22 --tmpfs /tmp --tmpfs /run -v /sys/fs/cgroup:/sys/fs/cgroup:ro -e container=docker --privileged debug-image /sbin/init


来源:https://stackoverflow.com/questions/50773691/run-gdb-inside-docker-container-running-systemd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!