大网数据广告活动
服务器运维问答

How to enable SELinux inside of a CentOS Docker container?

· 52CE 我爱测

I am trying to install SELinux inside of a Docker container in order to distribute an application that uses SELinux internally. The default CentOS image does not have SELinux installed: $ docker run -it centos:latest /bin/bash [r…

问题原文

原帖链接 · sffc · CC BY-SA 3.0

I am trying to install SELinux inside of a Docker container in order to distribute an application that uses SELinux internally.

The default CentOS image does not have SELinux installed:

$ docker run -it centos:latest /bin/bash
[root@38ae5a98273d /]# sestatus
bash: sestatus: command not found

After I install it from yum, SELinux is not enabled yet.

[root@38ae5a98273d /]# yum install policycoreutils selinux-policy-targeted
...
[root@38ae5a98273d /]# sestatus
SELinux status:                 disabled

All the documentation I've found says that you need to issue a system reboot in order to install it. However, I am not aware of a method to simulate a system reboot inside a Docker container.

How does one go about installing and enabling SELinux inside of a container?

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 3.0

SELinux is not namespaced, so individual containers cannot have their own separate SELinux policies. SELinux will always appear to be "disabled" in a container, though it is running on the host.

If your application requires SELinux, you cannot use it inside Docker. You will need to use a regular virtual machine.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。