When I tried to debug a C program using the gdb command in a Docker container, the following
warning: Error disabling address space randomization: Operation not permitted
I was angry.
(gdb) b 5
Breakpoint 1 at 0x117c: file test.c, line 5.
(gdb) r
Starting program: /home/user/dev/test
warning: Error disabling address space randomization: Operation not permitted
As you might expect, gdb uses system calls, but it seems that you cannot access the device of the host machine because you do not have the authority from inside the container.
Option to allow system call will be added.
$ docker run -it --cap-add=SYS_PTRACE --security-opt="seccomp=unconfined" [CONTAINER_NAME] /bin/bash
Write the following under service
.
docker-compose.yaml
cap_add:
- "SYS_PTRACE"
security_opt:
- "seccomp=unconfined"
https://sott0n.github.io/posts/docker_gdb/
Recommended Posts