The problem
I am able to set and reach a breakpoint if I compile and run from the host, but if I do it from within the docker container gdb does not
Rather than elevating the entire container, I was able to use the option
--security-opt seccomp=unconfined
to fix address space randomization problems.
Some also recommend enabling the ptrace capability with
--cap-add=SYS_PTRACE
but this didn't seem to have any effect for me.
Here are the same settings for Docker compose:
security_opt:
- seccomp:unconfined
cap_add:
- SYS_PTRACE
Details are taken from this Stack Overflow post.