Systemd (systemctl) \text{systemd(systemctl)} systemd(systemctl) Init \text{init} init, but /bin/bash \text{/bin/bash} /bin/bash.
The solution is to run a docker \text{docker} container in the background through init \text{init} init, and then use exec \text{exec} exec to enter the container. Note that different systems init \text{init} init programs have different paths.
For example CentOS 7 \text{CentOS 7} CentOS 7,
docker run -tid --name test_1 --privileged=true centos:latest /usr/sbin/init
docker exec -it test_1 /bin/bash
Copy the code
Ubuntu 16.04 \text{Ubuntu 16.04} Ubuntu 16.04,
docker run -tid --name test_2 --privileged=trueUbuntu 16.04 / sbin/init dockerexec -it test_2 /bin/bash
Copy the code
Docker \text{docker} docker container init \text{init} init –privileged=true \text{–privileged=true} –privileged=true is a must.