These are examples of how to debug common C/C++ bugs, such as logic errors, segmentation faults, and memory leaks, using CMake, GDB and Valgrind in Docker container. A more comprehensive tutorial could be found on my website.
$ docker build -f cpp.Dockerfile -t cpp-debug:0.0.1 .
$ docker run -it --rm --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $(pwd):/mnt cpp-debug:0.0.1
$ mkdir build
$ cd build
$ cmake ..
$ make