1.運行systemctl
構建Dockerfile的時候可以加入如下指令:
RUN apt install -y init
RUN mkdir /var/run/sshd
構建鏡像后,run容器的時候可以使用如下命令:
docker run -tid --name=containerName --privileged=true imageName /sbin/init
容器跑起來后既可以使用systemctl相關命令
2.set-hostname
無法設置屬性:無法設置靜態主機名:設備或資源繁忙
Could not set property: Failed to set static hostname: Device or resource busy
如果容器中掛在磁盤目錄,卸載掛載目錄。如果沒有掛載,退出容器,重新進入(Ctrl+p+q)