lost and found ( for me ? )

Ubuntu 16.04 : enable core dump in LXD containers

Host OS : Ubuntu 16.04
Container OS : CentOS 7

1. on the host OS(Ubuntu 16.04), configure core file pattern

edit core_pattern.

from
$ cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport %p %s %c %P

to
$ sudo sh -c "echo /tmp/core.%e.%p.%t > /proc/sys/kernel/core_pattern"

$ cat /proc/sys/kernel/core_pattern
/tmp/core.%e.%p.%t

If you want to make this permanently, add the following in /etc/sysctl.d/*.conf
$ tail -1 /etc/sysctl.d/99-sysctl.conf
kernel.core_pattern = /tmp/core.%e.%p.%t

2. on the host OS(Ubuntu 16.04), set core file size

$ sudo sh -c ulimit -c unlimited
unlimited

add the following lines in /etc/security/limits.conf
* soft core unlimited
* hard core unlimited

- launch a CentOS7 container

$ lxc launch centos7 centos01

$ lxc exec centos01 bash

[root@centos01 ~]# ulimit -c
0

[root@centos01 ~]# cat /proc/sys/kernel/core_pattern
/tmp/core.%e.%p.%t

[root@centos01 ~]# kill -6 298

[root@centos01 ~]# ls /tmp/core*
/tmp/core.<program name>.298.1499911251

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.