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?

  • Which one should i use? docker kill or docker stop?
  • docker mysql-server not starting on ubuntu [closed]
  • Meteor build locally or on aws host
  • docker push to a private repository
  • How to expose Kafka and Zookeeper ports in cloud foundry
  • Injecting the elastic beanstalk server URL into the node.js configuration using Docker
  • The monit of docker?
  • tar: Cannot read: Is a directory in docker
  • Where do untagged Docker images come from?
  • How to properly deal with .env files in docker
  • cURL to DropBox using Symfony 3
  • Docker Setup with a Mysql Container for a Python App
  • 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.