I want to modify the core_pattern
when building docker image, and my docker file is like this:
FROM centos:7
RUN echo "core-%e" > /proc/sys/kernel/core_pattern
Then I ran docker build
and I get an error
/bin/sh: /proc/sys/kernel/core_pattern: Read-only file system
Anybody help?
I needed this myself, I just found out how. it is not related to docker, but to linux in general. I am using ubuntu and I am 99% certain centos will behave the same in this regard.
it is edited via sysctl
command.
see example
bash$ cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport %p %s %c %d %P %E
bash$ sudo sysctl -w kernel.core_pattern="|/usr/share/apport/apport-kde %p %s %c %d %P %E"
kernel.core_pattern = |/usr/share/apport/apport-kde %p %s %c %d %P %E
bash$ cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport-kde %p %s %c %d %P %E
bash$
note that value starting with |
is to express commands. the core dump will be sent to the command as STDIN
Since you asked your question about docker, let me also provide a compatible answer.
FROM centos:7
RUN sudo sysctl -w kernel.core_pattern="core-%e"
for more info on the core pattern you can use in your file, instead of just %e, see https://sigquit.wordpress.com/2009/03/13/the-core-pattern/
also another related question/answer that has more details
https://unix.stackexchange.com/questions/343275/why-is-editing-core-pattern-restricted