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 access both ports 8080 and 9990 on bluemix single container for wildfly?
  • Docker command can't connect to Docker daemon
  • Nancy on Linux is using 100% CPU
  • Mount data volume to docker with read&write permission
  • how to install libcontainer docker in place of lxc-docker
  • how to install python package using tensorflow docker
  • Spring Bean injection fails on OpenShift
  • Enable webcam in docker application and access thru AWS ECS
  • Compatability of Dockerfile RUN Commands Cross-OS (apt-get)
  • Docker php5-fpm service exited (code 0)
  • DNS settings don't work in Docker CE
  • Sharing directories in a Docker container both with a Dockerfile and after the container is running
  • 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.