启动虚拟机里面的Docker时,发现怎么都启动不了,于是通过journalctl -xe命令查看日志,日志显示SELinux是开启的状态,那么只需要关闭SELinux即可。

SELinux(Security-Enhanced Linux) 是美国国家安全局(NSA)对于强制访问控制的实现,是Linux历史上最杰出的新安全子系统。

查看SELinux的状态

1
2
[root@mylocal ~]# getenforce
Enforcing

这表明SELinux是启动的状态。

永久关闭SELinux

编辑/etc/selinux/config文件

1
[root@mylocal ~]# vi /etc/selinux/config

SELINUX=enforcing改为SELINUX=disabled

1
2
3
4
5
6
7
8
9
10
11
12
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
- SELINUX=enforcing
+ SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

保存并退出后,要想使其生效,需要重启系统reboot

临时关闭

对于有些机器来说,不能随便重启时,可以使用如下命令临时禁用。

1
setenforce 0