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:
- It maybe affect the original core dump behaviour config for host.
- It can't specify the output place of core dump independently for every container.
- 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:
-
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:
- Require root
- Check /usr/libexec/docker-coredump-helper
- Copy /proc/sys/kernel/core_pattern to /var/run/docker/core_patterns/host
- 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.
-
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:
- Check "--core-pattern" option
- Save core-pattern value to /var/run/docker/core_patterns/[ContainerID]
Tree of core_patterns:
/var/run/docker/core_patterns/
├── host
├── [ContainerID1]
├── [ContainerID2]
├── ...
└── [ContainerIDn]
- 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/*.
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:
to store the core dump out of the container.
One proposal of implementation steps:
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-helperdocker-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:
If the value of "--coredump-helper" isn't specified, docker daemon need not do the above steps.
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 namespaceb)
docker run --core-pattern="/var/core.%s.%p.%e" [IMAGE] [CMD]// path is in the container mnt namespacec)
docker run [IMAGE] [CMD]// if "--core-pattern" not specified, default as: "#/var/run/docker/core_files/[ContainerID]/core.%p"Process steps: