Alpine Linux 3.11: NewRelic PHP Agent install fails to detect OS correctly, when dpkg installed

Environment and versions:

  • PHP v7.3.16 Docker image php:7.3.16-cli-alpine
  • Installed $PHPIZE_DEPS (autoconf dpkg-dev dpkg file g++ gcc libc-dev make pkgconf re2c)
  • NewRelic PHP Agent v9.10.0.262 tar package newrelic-php5-


When I try to build a Docker image for my application with NewRelic PHP Agent, and I have $PHPIZE_DEPS packages installed (required to build and install PHP/PECL extensions), newrelic-install scripts fails, saying I have a corrupt installation archive:

ERROR: the following directories could not be found:

ERROR: the following files could not be found:

I have found, that a dpkg package, installed as a part of $PHPIZE_DEPS, tricks install scripts to detect ostype variable as debian instead of alpine (Line 105):

# Get the OS type
if [ -f /etc/redhat-release -o -f /etc/redhat_version ]; then
elif [ -d /etc/dpkg ]; then
elif [ -f /etc/alpine-release ] || [ -d /etc/apk ]; then
elif [ -f /etc/release ]; then
  if grep Solaris /etc/release > /dev/null 2>&1; then

So, later, when time comes to detect a type of arch for agent, the script checks for x86 agent, while it’s not present in the tar (Line 272):

check_dir "${ilibdir}/agent/${arch}"
if [ -z "${ispkg}" ] && [ "${arch}" = "x64" ]; then
  # Only check for x86 directory on supported platforms.
  case "$ostype" in
    alpine|darwin|freebsd) ;;
    *) check_dir "${ilibdir}/agent/x86" ;;

Dockerfile to reproduce:

FROM php:7.3.16-cli-alpine

RUN set -eux \
    && apk add --no-cache --upgrade --virtual .purgable-deps $PHPIZE_DEPS \
    && curl \
            -fSL \
            -o /tmp/nr-php-agent.tar.gz \
    && cd /tmp && tar zxf nr-php-agent.tar.gz \
    && export NR_INSTALL_USE_CP_NOT_LN=1 \
    && export NR_INSTALL_SILENT=1 \
    && newrelic-php5-*/newrelic-install install


Install NewRelic PHP Agent after you remove $PHPIZE_DEPS installation:

apk del --purge .purgable-deps \
&& /newrelic-php5-*/newrelic-install install

Hi there, @yevhenii.dytyniuk.

Wow, thanks so much for the detailed post, and for adding this to the community so that anyone else running into this has a workaround.

We have also taken a look at this issue and found that as you mentioned the $PHPIZE_DEPS is creating a /etc/dpkg directory which is causing our install script to think the system is Debian.

As an additional workaround, you can also add RUN rm -rf /etc/dpkg to your Dockerfile before running the New Relic installer.

We are also tracking this internally for a more permanent fix in the future.

Thanks for bringing this up!

1 Like

Hi, @ntierney

Thanks for kind words :slight_smile:

What about the fix you suggest, I have posted a workaround solution with removing of $PHPIZE_DEPS before installing the agent. In addition, $PHPIZE_DEPS is not the set of packages you want be present in your Docker image at the end.

1 Like

@yevhenii.dytyniuk that’s a good workaround! I am going to let Engineering know about this as well. Thanks again!

1 Like