Dockerエラー:invoke-rc.d:policy-rc.dがstartの実行を拒否しました。



Docker Error Invoke Rc



ミラー作成時にサービスの開始中にエラーが発生しました:

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

1. /usr/sbin/policy-rc.dファイルは、管理者がインストール、アンインストール、および更新中に実行できるパッケージを制御するために使用されるため、ほとんどのディストリビューションには含まれていません。



Dockerコンテナでは、ほとんどのapt-getインストールはdockerビルドフェーズで行われます。この段階でサービスを開始/停止した場合、事故によりサービスが成功しない場合があり、必要ありません。ほとんどのサービスは、dockerrunまたはdockerstartで開始/停止します。

サービスを開始/停止する必要がある場合は、/ usr / sbin /policy-rc.dファイルの戻り値を0に変更できます。



0-許可されたアクション
1-不明なアクション(したがって、未定義のポリシー)
100-不明なinitscriptID
101-ポリシーで禁止されているアクション
102-サブシステムエラー
103-構文エラー
104- [予約済み]
105-動作が不確実、ポリシーが定義されていません。
106-アクションは許可されていません。返されたフォールバックアクションを使用する
(これは「許可」されることを意味します)代わりに。

参照: https://askubuntu.com/questions/365911/why-the-services-do-not-start-at-installation

2、ブログ: https://stackoverflow.com/questions/46247032/how-to-solve-invoke-rc-d-policy-rc-d-denied-execution-of-start-when-building



Here is a good post which tries to root cause the issue you are facing. Shorter way: RUN echo '#!/bin/sh exit 0' > /usr/sbin/policy-rc.d should resolve your issue OR 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 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 exit 0' > /usr/sbin/policy-rc.d