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.

leeyc
  • 385
  • 2
  • 5
  • 13

1 Answers1

7

You can set the limits on the container on docker run with the --ulimit flag.

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

Note that "unlimited" is not a supported value since it is not actually a real value, but -1 is equivalent to it:

$ docker run -it --ulimit core=-1 ubuntu:18.04 sh -c 'ulimit -a | grep core'
coredump(blocks)     unlimited
~ $
AKX
  • 152,115
  • 15
  • 115
  • 172
cpuguy83
  • 5,794
  • 4
  • 18
  • 24
  • If we want to change it permenantly what we can use? Can we push above line docker run --ulimit core= to the file /etc/security/limits.conf. – Tejaswi Burgula Aug 08 '16 at 12:35
  • 1
    You can set this at the daemon level `--default-ulimit core=` – cpuguy83 Aug 08 '16 at 14:57
  • Thanks. its working.. but if i run 'docker run --ulimit core=9999999999 -ti -d --volumes-from test-vol-$5 -p $1:13456 -e "test_prod_id=$2" -e "ip_v4_address=$4" test:$5' i can able to see the limits for container root. But i am not able login other users of container from container root. Is there any mistake in above command? – Tejaswi Burgula Aug 21 '16 at 06:10