简体   繁体   中英

gdb debug in docker failed

envs: host:centos docker:ubuntu 16 nivida-docker program:c++ websocket

desc: when I use gdb in docker ,I can't use breakpoint ,it just says: warning: error disabling address space randomization: operation not permitted .I see alot of resolutions to this question,all of them tell me to add : --cap-add=SYS_PTRACE --security-opt seccomp=unconfined to my docker file ,so I did it.here is my docker file:

!/bin/sh
SCRIPT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
PROJECT_ROOT="$( cd "${SCRIPT_DIR}/.." && pwd )"
echo "PROJECT_ROOT = ${PROJECT_ROOT}"

run_type=$1
docker_name=$2
sudo docker run \
  --name=${docker_name} \
  --privileged \
  --network host \
  -it --rm \
  --cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
  -v ${PROJECT_ROOT}/..:/home \
  -v /ssd3:/ssd3 \
  xxxx/xx/xxxx:xxxx \
  bash

but when restart the container and run gdb ,it always killed like below:

(gdb) r -c conf/a.json -p 8075
Starting program: /home/Service/bin/Service --args -c conf/a.json -p 8075
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Killed

I don't known where is wrong ,anyone have any opinions?

尝试这个

docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM