How can I keep docker container alive long enough for New Relic send traced exceptions?

We are running a php cli command in a docker container with New Relic deamon installed to track exceptions. The problem is that New Relic sends exception traces on an interval of 1 minute, but when our php process crashes due to an exception, the container gets killed right away.

Is there a (simple) solution to keep the container alive for about one minute after the php process has died, for example by wrapping it in some other script/program?

  • Why are Docker build commands running so slow in Elastic Beanstalk?
  • Call rabbitmq from nodejs
  • Changing /proc/sys/kernel/core_pattern file inside docker container
  • Pycharm 2017 docker support for debugging
  • Image push docker Registry Fails
  • fluentd JSON Parser: get Messages that cannot be parsed
  • Rails scaffolding with docker and file ownership
  • Deploying containerised node.JS application through mesos-marathon
  • git runner is unable to access
  • do not change directory if gitbash is started by docker quickstart terminal shortcut
  • Docker mac symfony 3 very slow
  • docker nginx stream balancer 404
  • One Solution collect form web for “How can I keep docker container alive long enough for New Relic send traced exceptions?”

    Thanks to the comment of user2915097, which got me thinking, we’ve found a solution. We wrote a small script which we use an entrypoint of the container and sleep when the script fails.


    eval "$@" || (echo 'Delaying exit for 60 seconds for New Relic to send its report...' && sleep 60)

    Lines to add to Dockerfile:

    COPY cron-php-entrypoint /usr/local/bin/
    ENTRYPOINT ["cron-php-entrypoint"]
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.