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?

  • How can i pre-install plugins in jenkins on Windows docker?
  • Why do I get unauthorized: authentication required from a docker pull from docker hub?
  • Docker image for aspNet core hangs on windows
  • Invalid US-ASCII character using SASS
  • Where does Travis CI put my source files?
  • Build Eclipse CDT project in docker
  • ENTRYPOINT with environment variables is not acepting new params
  • Accessing system variables through HHVM
  • How to move docker network from old to new container?
  • Execution of python script hangs while executing docker exec command
  • docker login with non interactive session returns 401
  • Prune unused images in OpenShift Origin 1.1.6
  • 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.

    cron-php-entrypoint:

    #!/bin/sh
    
    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.