问题
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