How to disable core file dumps in docker container

前端 未结 3 1516
甜味超标
甜味超标 2021-01-04 02:02

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 com

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-04 02:47

    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.)
    

    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)
    

提交回复
热议问题