本文主要是介绍How to solve “invoke-rc.d: policy-rc.d denied execution of start.” when building a container Ubuntu,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题场景:通过Dockerfile构建基于ubuntu的apache服务器时报错
invoke-rc.d: policy-rc.d denied execution of start.
在stackoverflow站点上看到一个问题回答,借鉴后解决了我的问题,答案如下
Here is a good post which tries to root cause the issue you are facing.Shorter way:RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d should resolve your issue ORIf that doesn't resolve the issue, try running your docker container with privileged option. Like this, docker run --privileged -d -ti DOCKER_IMAGE:TAGIdeally, I would not recommend running container with privileged option unless its 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
在Dockerfile中加上
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d
重新构建后就没有报这个错误了
这篇关于How to solve “invoke-rc.d: policy-rc.d denied execution of start.” when building a container Ubuntu的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!