Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable core file dumps in docker container

My PHP container runs puppeteer to generate PDF. By generating a PDF document, it also creates two core dump files inside my container. I am not sure where they actually come from.

The host/server is CentOS 7.

I've checked following:

  1. No application error log, Browsershot/puppeteer is running without errors.
  2. No error log (e.g. segfault) found in /var/log/messages

I've tried to disable core dumps

By following Disable core dumps section of https://linux-audit.com/understand-and-configure-core-dumps-work-on-linux/, I've done:

  1. Adding following content to /etc/security/limits.conf
* soft core 0
* hard core 0
  1. Created a disable-core-dumps.sh by: echo “ulimit -c 0 > /dev/null 2>&1” > /etc/profile.d/disable-coredumps.sh

  2. Added following content to /etc/systemd/coredump.conf

[Coredump]

Storage=none
ProcessSizeMax=0
  1. And reboot the server and the container.

  2. I've also tried to set ulimit -c 0 inside the container (alpine)

None of the tricks above work for me. Everytime the puppeteer generates a PDF it always create two core dump files like below:

core.131 core.52

The core files look like:

Core dump file content

Can anyone helps me to disable the core dumps? Thanks a lot.

like image 671
Jonathan Avatar asked Nov 05 '19 03:11

Jonathan


People also ask

Can I delete core dumps?

Yes, you can safely delete the core files.

Why do core dumps happen?

A core dump or a crash dump is a memory snapshot of a running process. A core dump can be automatically created by the operating system when a fatal or unhandled error (for example, signal or system exception) occurs. Alternatively, a core dump can be forced by means of system-provided command-line utilities.

How to disable core dumps?

Created a disable-core-dumps.sh by: echo “ulimit -c 0 > /dev/null 2>&1” > /etc/profile.d/disable-coredumps.sh And reboot the server and the container. I've also tried to set ulimit -c 0 inside the container (alpine) None of the tricks above work for me. Everytime the puppeteer generates a PDF it always create two core dump files like below:

How do I delete a docker container in Linux?

Docker rm is a Docker command used to delete or remove one or more containers. In order to remove the container, it should be in the stopped state; however, we can forcefully remove a running container using the ‘-f’ flag. We need a container ID or container name to remove the container.

How do I open a core dump file on a VM?

This article discusses how to use Docker to open a core dump file on a Windows virtual machine (VM). To complete this section, you should have at least one core dump file copied on your Windows VM in any folder. You'll learn how to open a core dump file on another Linux VM by using Docker.

What is a docker container image?

A Docker container image is a lightweight, standalone, executable software package that includes everything that's required to run an application: Code, runtime, system tools, system libraries, and settings. Simply put, you can use Docker containers to run and deploy your applications.


1 Answers

You have to start your container with the option --ulimit core=0 to disable coredumps.

Reference: https://docs.docker.com/engine/reference/commandline/run/#set-ulimits-in-container---ulimit

Example

On the host, temporarily set the coredump path to /tmp for verification:

echo '/tmp/core.%e.%p' | sudo tee /proc/sys/kernel/core_pattern

Start a container as usual and force a core dump:

docker run --rm -it bash
(inside the container)
# yes > /dev/null &
# kill -SIGABRT $(pidof yes)
# ls /tmp
(shows core.yes.<pid>)

Now, with --ulimit core=0:

docker run --ulimit core=0 --rm -it bash
(inside the container)
# yes > /dev/null &
# kill -SIGABRT $(pidof yes)
# ls /tmp
(No entries)
like image 170
Philipp Ludwig Avatar answered Sep 19 '22 12:09

Philipp Ludwig