docker建立centos映象無法使用systemctl
阿新 • • 發佈:2018-12-19
docker獲取centos映象,裡面執行安裝lnmp之後 發現使用systemctl無法使用
[[email protected] /]# systemctl restart nginx
Failed to get D-Bus connection: Operation not permitted
解決辦法
1: docker stop 92926bd84d70
2: docker export 92926bd84d70 > centos_lnmp_laster.tar
3:cat centos_lnmp_laster.tar | docker import - centos_lnmp
4: docker run --privileged -itd -p 8088:80 -p 33006:3306 c5062bdb9131 /usr/sbin/init
docker ps -a檢視啟動映象
[email protected]:/data# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1850715a5140 c5062bdb9131 "/usr/sbin/init" 28 minutes ago Up 28 minutes 0.0.0.0:8088->80/tcp, 0.0.0.0:33006->3306/tcp trusting_goldberg
docker exec登陸
[email protected]:/data# docker exec -it 1850715a5140 /bin/bash
[[email protected] /]# systemctl restart nginx
[[email protected] /]#