Docker下構建centos7容器沒法使用systemctl命令的解決辦法

最近在使用docker 構建centos7 容器時,發現沒法使用systemctl 命令。後來萬能的百度解決了問題,隨記之以備後用。docker

解決辦法:centos

docker run --privileged -it -d centos:7.6.1810 /usr/sbin/init #注意2點:1. --privileged 參數必須加,2. /usr/sbin/init做爲容器的啓動命令

驗證方法:bash

docker exec -it $containerID bash #進入容器的bash命令行
systemctl #驗證systemctl 命令是否可用
相關文章
相關標籤/搜索