Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve "invoke-rc.d: policy-rc.d denied execution of start." when building a container Ubuntu 14.04 and installing apache2?

Tags:

docker

apache

I am trying to install apache2 after a building image process. This is the code I am using in the Dockerfile.

FROM ubuntu:14.04
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

ENV DEBIAN_FRONTEND noninteractive

RUN sudo apt-get update
RUN sudo apt-get install -y apache2

After the process I get the apache installed but I get the follow error (red display in terminal)

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

How to solve that issue? If it is an issue.

like image 648
IgorAlves Avatar asked Sep 15 '17 20:09

IgorAlves


1 Answers

Here is a good post which tries to root cause the issue you are facing.

Shorter way:

  1. RUN printf '#!/bin/sh\nexit 0' > /usr/sbin/policy-rc.d should resolve your issue OR

  2. If that doesn't resolve the issue, try running your docker container with privileged option. Like this, docker run --privileged -d -ti DOCKER_IMAGE:TAG

Ideally, I would not recommend running container with privileged option unless it's a test bed container. The reason being running a docker container with privileged gives all capabilities to the container, and it also lifts all the limitations enforced. In other words, the container can then do almost everything that the host can do. But this is not a good practice. This defeats the docker purpose of isolating from host machine.

The ideal way to do this is to set capabilities of your docker container based on what you want to achieve. Googling this should help you out to provide appropriate capability for your docker container.

like image 120
Nikhil Katre Avatar answered Oct 21 '22 18:10

Nikhil Katre