How do I coredump the process of pid 1 in the docker container?

problem description

background: there is an application written by golang online, which runs in the docker container, and uses cgo to call the so dynamic library. It will crash because of some circumstances on the weekend, and recover will not catch it. It is suspected that it is the problem of so. I hope to find out the cause of the crash by analyzing the core file.

so now the core question is: how to generate core files for processes with pid 1 in the container?

what methods have you tried

putting aside the container, we know that Go applications need

to generate core files in the system.
  1. the system supports generating core-enter ulimit-c unlimited on the currently logged in terminal.
  2. set storage location- echo"/ tmp/core.%t.%e.%p" | sudo tee / proc/sys/kernel/core_pattern
  3. for golang applications, you need to add the environment variable at startup: GOTRACEBACK=crash.

for containers, the first two settings are handled:

  1. docker run plus parameter -- ulimit core=-1-- security-opt seccomp=unconfined .
  2. The
  3. container inherits the / proc/sys/kernel/core_pattern configuration settings of the host. Here you choose to modify the configuration of the host directly

trigger the way to generate coredump. Here you choose to send a signal to the process. You have tried two ways

  1. docker exec enter the related container and execute kill-SIGQUIT 1
  2. execute docker kill-- signal=SIGQUIT < container_id > on the host machine

version of related software

what result do you expect? What is the error message actually seen?

PS: to avoid container restart caused by pid 1 suspension, a directory of the host is mounted into the / tmp directory of the container.

The actual result of

is that no core file is generated in the / tmp directory.

for comparison, I can generate the core file (actually the core file of the gops process) by Ctrl +\ manually aborting gops trace 1 in the same container I"m running.

Jun.14,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8fba9-1280.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8fba9-1280.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?