0

I get the following error when installing PHP FPM:

Creating config file /etc/php/7.0/fpm/php.ini with new version
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.

I tried the following tweaks in my dockerfile:

RUN echo exit 0 > /usr/sbin/policy-rc.d
RUN /etc/init.d/php7.0-fpm start
RUN service php7.0-fpm start

None of this works, and PHP FPM isn't running on boot.

However if I ssh in and manually run the following command:

service php7.0-fpm start

Then it starts working! What is the problem here?

Jimmy
  • 269
  • 4
  • 7
  • 23

2 Answers2

1

The problem is that you have to provide the full path to the utility you invoked. When you do it from the ssh-session you have some PATH environment variable containing the list of directories looked for the given utility. And there is no such list in the docker.

Run manually:

which service

You'll get the full path to the utility. Provide that path to the config instead of single utility name.

Kondybas
  • 6,964
  • 2
  • 20
  • 24
  • I thought this was a shoe in to work, but it still didn't. I tried both: ```RUN usr/sbin/service php7.0-fpm start``` and ```RUN /usr/sbin/service php7.0-fpm start``` as part of the docker file and no luck, yet when I login and run it, it works fine! – Jimmy Sep 24 '18 at 16:12
0

invoke-rc.d: policy-rc.d denied execution of start.

Try adding:

RUN printf "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d
RUN chmod +x /usr/sbin/policy-rc.d

See: How to solve “invoke-rc.d: policy-rc.d denied execution of start.”


invoke-rc.d: could not determine current runlevel

Try:

RUN RUNLEVEL=1 dpkg --configure -a

or:

RUN RUNLEVEL=1 dpkg-reconfigure php7.0-fpm
kenorb
  • 6,499
  • 2
  • 46
  • 54