Skip to content

Proposal: Core dump in docker #19289

Description

@zhangjianfnst

In the current docker, we can only use the system global config of /proc/sys/kernel/core_pattern to specify the output place of core dump in container. There are several problems in this way:

  1. It maybe affect the original core dump behaviour config for host.
  2. It can't specify the output place of core dump independently for every container.
  3. The specified output place of core dump is in the container, but there are no tools (gdb e.g.) to investigate the core dump file in the container, and the core dump file may be too large. So it's better
    to store the core dump out of the container.

One proposal of implementation steps:

  1. Introduce "--coredump-helper" option in docker daemon, this option enables and specifies core dump helper program.
    E.g.:
    docker daemon --coredump-helper=/usr/libexec/docker-coredump-helper

    docker-coredump-helper is an executable program built from a project of docker-coredump-helper (it doesn't exsist now, also need to be implemented).

    Process steps:

    1. Require root
    2. Check /usr/libexec/docker-coredump-helper
    3. Copy /proc/sys/kernel/core_pattern to /var/run/docker/core_patterns/host
    4. Set /proc/sys/kernel/core_pattern with "|/usr/libexec/docker-coredump-helper %c %d %e %E %g %h %i %I %p %P %s %t %u"

    If the value of "--coredump-helper" isn't specified, docker daemon need not do the above steps.

  2. Introduce "--core-pattern" option in docker run/create, this option specifies the container core pattern.
    E.g.:
    a) docker run --core-pattern="#/var/core.%s.%p.%e" [IMAGE] [CMD] // path with '#' means it would be in host mnt namespace
    b) docker run --core-pattern="/var/core.%s.%p.%e" [IMAGE] [CMD] // path is in the container mnt namespace
    c) docker run [IMAGE] [CMD] // if "--core-pattern" not specified, default as: "#/var/run/docker/core_files/[ContainerID]/core.%p"

    Process steps:

    1. Check "--core-pattern" option
    2. Save core-pattern value to /var/run/docker/core_patterns/[ContainerID]
    Tree of core_patterns:
     /var/run/docker/core_patterns/
     ├── host
     ├── [ContainerID1]
     ├── [ContainerID2]
     ├── ...
     └── [ContainerIDn]
    
    1. When core dump is triggered, the docker-coredump-helper is executed. This program can judge the core dump source process and dispatch the core dump file according the config of /var/run/docker/core_patterns/*.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/runtimeRuntimekind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shiny

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions