DockerのCentOSでSystemdが使えない(Failed to get D-Bus connection: Operation not permitted)

docker
CentOS7

Failed to get D-Bus connection: Operation not permittedというエラーで、
systemctlが使えないのを解消

起動方法を変える

$ docker run -d --privileged --name name_of_container centos7 /sbin/init

ポイント

  • --privilegedをつけて起動(本番ではやっちゃだめ)
  • -itはつけない
  • name_of_containerは好きな名前

コンテナに入る

docker exec -it name_of_container bash

以上

参考