Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Relic Solution: Keeping the PHP Agent up to date in Containerised Applications



When installing the New Relic PHP Agent within Docker, our installation documentation provides an example Dockefile which downloads the latest PHP agent package from New Relic’s tar file download site:

FROM php:7.1

  curl -L PHP_AGENT_URL | tar -C /tmp -zx && \
  export NR_INSTALL_USE_CP_NOT_LN=1 && \
  export NR_INSTALL_SILENT=1 && \
  /tmp/newrelic-php5-*/newrelic-install install && \
  rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* && \
  sed -i \
      -e 's/newrelic.appname = "PHP Application"/newrelic.appname = "YOUR_APPLICATION_NAME"/' \
      -e 's/;newrelic.daemon.app_connect_timeout =.*/newrelic.daemon.app_connect_timeout=15s/' \
      -e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \

The PHP_AGENT_URLvariable is the URL defined by the user for their desired PHP agent version they wish to download. The documentation provides a link to the most recent release of the Agent.

An issue here is that once the PHP agent is updated, the Dockerfile build will fail due to the latest release of the PHP agent being found here while the archived versions of the PHP agent being found here. Another issue is that the user will need to manually insert the new download URL each time a new Agent version is released.

If you like to keep up to date with the releases of the PHP Agent in your containerised application, one workaround here is to use curl to fetch the HTML content and then use sed to grab the most recent release version number from the HTML source.

  export NR_VERSION=$(curl -sS | sed -n 's/.*>\(.*linux\).tar.gz<.*/\1/p') && \
  curl -L${NR_VERSION}.tar.gz | tar -C /tmp -zx

Please note that this workaround could break if New Relic change the structure of the tar download website.


Hi we are having the same Issue. Thanks for your Workaround will give it a try. But we would appreciate something like a stable release so the agent is always up to date and this workaround would be obsolete.

Kind regards


@andrew.tur Understand that a workaround may not be ideal but hoping it provided a good solution for your needs. Would be curious to hear how it went for you? :slight_smile: