How to disable core file dumps in docker container
i have this problem too on the docker swarm service and --ulimit core=0 does not work in swarm service i used below command and worked for me in docker swarm service!
sysctl -w kernel.core_pattern=/dev/null
For those using docker-compose, in the .yml
file set ulimits
:
services:
app:
ulimits:
core:
hard: 0
soft: 0
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)