docker 不能运行 systemctl

docker centos7运行systemctl start nginx 报错:

1
Failed to get D-BUS connection: Operation no permitted

解决方法:

在启动容器的时候添加上-d参数就可以了

1
2
3
docker run -itd --privileged -p 3306:3306 -v /opt/data/:/opt/mysql/data 镜像ID /usr/sbin/init

docker exec -it 容器ID /bin/bash