Run following commands in a start up script of docker container.
echo '/tmp/core.%h.%e.%t' > /proc/sys/kernel/core_pattern ulimit -c unlimited
- In some case, default value of
/proc/sys/kernel/core_patternis pipe. Then, it should be configured explicitly
- Configure size of core file by
- Enable debug option if the program is compiled by yourself. Install debug symbol if it's from package manager.
- Do not delete source code in docker image.
docker runto allow write permission for
- Check your container ID by
docker ps -acommand
- Create docker image from the container by
docker commit -m "coredump" 92b8935a7cd7(92b8935a7cd7 is container ID）
docker run -it <created image ID> shand boot a container in a state immediately after segmentation falut
- Install gdb if it hasn't been installed
gdb /path/to/binary /path/to/corefile
- Enjoy debugging
Classic DEV Post from Nov 13 '19