Browse code

Error if Docker daemon starts with BTRFS graph driver and SELinux enabled

The Docker btrfs graph driver does not interact well with SELinux at present.
If btrfs mounts the same file in several locations, the same SELinux label will
be applied to all mountpoints. In the context of the graph driver, things such
as shared libraries become inaccessible to containers due to SELInux, causing
all dynamically linked applications to fail when run in a container.

Consequently, error when we detect the daemon is being run with SELinux enabled
and the btrfs driver. Documentation has been added for this behavior.

Docker-DCO-1.1-Signed-off-by: Matthew Heon <mheon@redhat.com> (github: mheon)

Matthew Heon authored on 2014/06/05 05:38:06
Showing 4 changed files
... ...
@@ -778,6 +778,11 @@ func NewDaemonFromDirectory(config *daemonconfig.Config, eng *engine.Engine) (*D
778 778
 	}
779 779
 	utils.Debugf("Using graph driver %s", driver)
780 780
 
781
+	// As Docker on btrfs and SELinux are incompatible at present, error on both being enabled
782
+	if config.EnableSelinuxSupport && driver.String() == "btrfs" {
783
+		return nil, fmt.Errorf("SELinux is not supported with the BTRFS graph driver!")
784
+	}
785
+
781 786
 	daemonRepo := path.Join(config.Root, "containers")
782 787
 
783 788
 	if err := os.MkdirAll(daemonRepo, 0700); err != nil && !os.IsExist(err) {
... ...
@@ -66,7 +66,7 @@ func main() {
66 66
 		flCa                 = flag.String([]string{"-tlscacert"}, dockerConfDir+defaultCaFile, "Trust only remotes providing a certificate signed by the CA given here")
67 67
 		flCert               = flag.String([]string{"-tlscert"}, dockerConfDir+defaultCertFile, "Path to TLS certificate file")
68 68
 		flKey                = flag.String([]string{"-tlskey"}, dockerConfDir+defaultKeyFile, "Path to TLS key file")
69
-		flSelinuxEnabled     = flag.Bool([]string{"-selinux-enabled"}, false, "Enable selinux support")
69
+		flSelinuxEnabled     = flag.Bool([]string{"-selinux-enabled"}, false, "Enable selinux support. SELinux does not presently support the BTRFS storage driver")
70 70
 	)
71 71
 	flag.Var(&flDns, []string{"#dns", "-dns"}, "Force Docker to use specific DNS servers")
72 72
 	flag.Var(&flDnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains")
... ...
@@ -74,7 +74,7 @@ unix://[/path/to/socket] to use.
74 74
   Print version information and quit. Default is false.
75 75
 
76 76
 **--selinux-enabled**=*true*|*false*
77
-  Enable selinux support. Default is false.
77
+  Enable selinux support. Default is false. SELinux does not presently support the BTRFS storage driver.
78 78
 
79 79
 # COMMANDS
80 80
 **docker-attach(1)**
... ...
@@ -73,7 +73,7 @@ expect an integer, and they can only be specified once.
73 73
       -p, --pidfile="/var/run/docker.pid"        Path to use for daemon PID file
74 74
       -r, --restart=true                         Restart previously running containers
75 75
       -s, --storage-driver=""                    Force the Docker runtime to use a specific storage driver
76
-      --selinux-enabled=false                    Enable selinux support
76
+      --selinux-enabled=false                    Enable selinux support. SELinux does not presently support the BTRFS storage driver
77 77
       --storage-opt=[]                           Set storage driver options
78 78
       --tls=false                                Use TLS; implied by tls-verify flags
79 79
       --tlscacert="/home/sven/.docker/ca.pem"    Trust only remotes providing a certificate signed by the CA given here