-1

Could you please advise on setting up permissions with the docker file for the www-data user to start PHP agent within the docker container running on GKE. Please advise.

enter image description here

    FROM php:7.4-fpm as test

RUN \
  curl -L https://download.newrelic.com/php_agent/release/newrelic-php5-10.1.0.313-linux.tar.gz | 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/"REPLACE_WITH_REAL_KEY"/"My-Key"/' \
      -e 's/newrelic.appname = "PHP Application"/newrelic.appname = "test"/' \
      -e 's/;newrelic.daemon.app_connect_timeout =.*/newrelic.daemon.app_connect_timeout=15s/' \
      -e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \
      /usr/local/etc/php/conf.d/newrelic.ini


USER www

php app related build. etc....

Thank you very much.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
Ishan
  • 21
  • 1
  • 6

1 Answers1

1

In your docker file you are changing the user to USER www due to that it's not running.

As suggested in error it is expected to run by the root user so you can remove the USER www line from docker and try building a new docker image with --no-cache and it will start working with root.

Official ref : https://docs.newrelic.com/docs/apm/agents/php-agent/advanced-installation/docker-other-container-environments-install-php-agent/

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
  • Thank you for your response. If I switch to root my application is also running under root which I want to avoid. As per the New Relic documentation root permissions are required to install. But its not required to run the agent. "Running the agent does not require root access. The agent does need read/write access to the following files (the location of these files can be" docs.newrelic.com/docs/apm/agents/php-agent/troubleshooting/determine-permissions-requirements-php/ I'm looking for a workaround to start the agent using USER www. – Ishan Oct 03 '22 at 06:37
  • Is it possible to run New Relic under root and my application under www. (two users) ? – Ishan Oct 03 '22 at 06:38
  • you can create the group using addgroup command in linux or change the file permission using the chmod or chown for changing the ownership of file. you can create simply group or user and use that simply – Harsh Manvar Oct 03 '22 at 06:46
  • you can `RUN useradd -ms /bin/bash admin, COPY --chown=admin:admin app /app` to change the file permission and change user also as per need. – Harsh Manvar Oct 03 '22 at 06:50