You may be filling up the disk with core dumps causing outages in your application. Or you’re troubleshooting Docker failures and don’t need 3000 core dumps. Whatever it is, you’ve decided to limit the size the core dumps can consume within Docker. Fortunately, this is a really easy fix.
The docker run
command has a flag for --ulimit
which can be used to set all sorts of resource limits within the container. If you’re familiar with Linux, you’ll likely have encountered ulimit in some sort of context before, and it’s behavior is exactly the same in Docker. In order to limit the core size, we need to run our containers with something like this:
docker run --ulimit core=<size> alpine
If you have a specific size you want the core dumps to abide by, you can replace size in the above command with that value. If you don’t want core dumps at all, you can set the size to 0 like below:
docker run --ulimit core=0 alpine
And if you want your core size to be unlimited, you can replace size with -1 like below.
docker run --ulimit core=-1 alpine
That’s all there is to it. The --ulimit
flag in Docker has a lot of other resource limits you can set. If you want more information, Docker has some great documentation at https://docs.docker.com/engine/reference/commandline/run/#ulimit
Great post. Core dumps from containers triggered icinga alerts and our unix team hate it. Now i can turn in off. Thank you.