Docker 是否可以在不停止容器的情况下将“--privileged=true”属性分配给此容器?

Docker 是否可以在不停止容器的情况下将“--privileged=true”属性分配给此容器?,docker,Docker,我遇到了这个问题: 当我执行systemctl时,出现以下错误: [root@eb00fc55c925 yum.repos.d]# systemctl start salt-minion System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down 我发现解决方案运行容器应该添加--privileged=true: doc

我遇到了这个问题: 当我执行
systemctl
时,出现以下错误:

[root@eb00fc55c925 yum.repos.d]# systemctl start salt-minion
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
我发现解决方案运行容器应该添加
--privileged=true

docker run -tid --name test --privileged=true centos /sbin/init

docker exec -it test /bin/bash
但是现在,在我的容器中,我已经安装了一些软件并为其配置了网络。 如果I
exit
it,将丢失为其配置的网络


是否可以将
--privileged=true
属性分配给此容器而不丢失为其配置的网络?

不,您不能这样做,因为操作系统是如何分配特权的。

systemctl
这样的命令在Docker中基本不起作用。您应该在它自己的容器中作为单个前台进程运行您试图运行的命令。(您显示的
docker run
命令将尝试重新配置一些您确实不希望的主机系统内容。)