How to disable core file dumps in docker container

前端 未结 3 1506
甜味超标
甜味超标 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:43

    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

    0 讨论(0)
  • 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.<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)
    
    0 讨论(0)
  • 2021-01-04 02:47

    For those using docker-compose, in the .yml file set ulimits:

    services:
        app:
            ulimits:
                core:
                    hard: 0
                    soft: 0
    
    0 讨论(0)
提交回复
热议问题