4

I want to set core file size to unlimited in a Docker container.

I tried changing limits.conf in container.

Dockerfile

RUN sed -i.bak '/\# End of file/ i\\* soft core unlimited' /etc/security/limits.conf
RUN sed -i.bak '/\# End of file/ i\\* hard core unlimited' /etc/security/limits.conf

I restarted the container but that didn't work.

Core file size is always 0.

I can use the command

$ ulimit -c unlimited

for setting core file size. But I have to use the command for another application. So I don't want us these commands.

Please let me know how I can change the core file size in a Docker container.

4

1 回答 1

6

docker run您可以使用--ulimit标志设置容器的限制。

docker run --ulimit core=<size> ...

请注意,“unlimited”不是一个受支持的值,因为它实际上不是一个实际值,而是-1等价于它:

$ docker run -it --ulimit core=-1 ubuntu:18.04 sh -c 'ulimit -a | grep core'
coredump(blocks)     unlimited
~ $
于 2015-09-29T23:44:50.203 回答