在docker容器中Centos7执行
systemctl --type=service --all
systemctl命令时,报上面错
解决方案:
用docker run 特权模式
docker run -d -it --privileged ContainerId /usr/sbin/init
就能解决,如果用docker-compos,只需在docker-compose.yml中加上相应的即可:
version: '3'
services:
centos:
image: centos:7
container_name: centos
tty: true
privileged: true
ports:
- 8885:21007
- 8886:21008
- 3308:3306
- 5435:5432
- 9012:9011
- "8122:22"
- "8121:21"
volumes:
- /home/hello/workspace:/home/hello/workspace
restart: always
command: /usr/sbin/init
主要是privileged: true和command: /usr/sbin/init