Permalink
Browse files

Remount /var/lib/docker as --private to fix scaling issue

If an admin mounts all file systems as -rshared (Default on RHEL and Fedora)
we see a scaling problem as the number of container increase.

Basically every new container needs to have it new mounts in /var/lib/docker
shared to all other containers, this ends up with us only able to scale to
around 100 containers, before the system slows down.

By simply bind mounting /var/lib/docker on its and then setting it private,
the scaling issue goes away.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
  • Loading branch information...
rhatdan committed Mar 27, 2014
1 parent be5c65c commit 792bb41e524615486ef8266b7bf4804b4fe178f1
Showing with 21 additions and 0 deletions.
  1. +21 −0 runtime/runtime.go
View
@@ -10,6 +10,7 @@ import (
"github.com/dotcloud/docker/graph"
"github.com/dotcloud/docker/image"
"github.com/dotcloud/docker/pkg/graphdb"
"github.com/dotcloud/docker/pkg/mount"
"github.com/dotcloud/docker/pkg/sysinfo"
"github.com/dotcloud/docker/runconfig"
"github.com/dotcloud/docker/runtime/execdriver"
@@ -59,6 +60,22 @@ type Runtime struct {
execDriver execdriver.Driver
}
// Mountpoints should be private to the container
func remountPrivate(mountPoint string) error {
mounted, err := mount.Mounted(mountPoint)
if err != nil {
return err
}
if !mounted {
if err := mount.Mount(mountPoint, mountPoint, "none", "bind,rw"); err != nil {
return err
}
}
return mount.ForceMount("", mountPoint, "none", "private")
}
// List returns an array of all containers registered in the runtime.
func (runtime *Runtime) List() []*Container {
containers := new(History)
@@ -654,6 +671,10 @@ func NewRuntimeFromDirectory(config *daemonconfig.Config, eng *engine.Engine) (*
}
utils.Debugf("Using graph driver %s", driver)
if err := remountPrivate(config.Root); err != nil {
return nil, err
}
runtimeRepo := path.Join(config.Root, "containers")
if err := os.MkdirAll(runtimeRepo, 0700); err != nil && !os.IsExist(err) {

0 comments on commit 792bb41

Please sign in to comment.