concept SELinux in category docker

appears as: SELinux
Docker in Practice, Second Edition

This is an excerpt from Manning's book Docker in Practice, Second Edition.

You may run into difficulties if your host runs SELinux. If SELinux policy is enforced, the container may not be able to write to the /var/db/tables directory. You’ll see a “permission denied” error. If you need to work around this, you’ll have to talk to your sysadmin (if you have one) or switch off SELinux (for development purposes only). See technique 113 for more on SELinux.

SELinux is a tool built and open-sourced by the United States’ National Security Agency (NSA) that fulfills their need for strong access control. It has been a security standard for some time now, and it’s very powerful. Unfortunately, many people simply switch it off when they encounter problems with it, rather than take the time to understand it. We hope the technique shown here will help make that approach less tempting.

This technique assumes you have a SELinux-enabled host. This means you must first install SELinux (assuming it’s not already installed). If you’re running Fedora or some other Red Hat–based system, you likely have it already.

To determine whether you have SELinux enabled, run the command sestatus:

# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          permissive
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28

The first line of the output will tell you whether SELinux is enabled. If the command isn’t available, you don’t have SELinux installed on your host.