From 4b8c41c4a2591797f97ad079e4314b21498ba732 Mon Sep 17 00:00:00 2001 From: unclejack Date: Sat, 19 Oct 2013 01:44:06 +0300 Subject: [PATCH] disallow / as source for bind mount in the cli This makes the docker cli reject docker run commands which include bind mounts like "/:/some/path/in/the/container". Bind mounting the root directory is a bad idea and the cli should throw an error right away. The same check will also be made by the remote API via another commit. --- container.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/container.go b/container.go index a22484c2d6..92e05283d1 100644 --- a/container.go +++ b/container.go @@ -251,6 +251,9 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig, for bind := range flVolumes { arr := strings.Split(bind, ":") if len(arr) > 1 { + if arr[0] == "/" { + return nil, nil, cmd, fmt.Errorf("Invalid bind mount: source can't be '/'") + } dstDir := arr[1] flVolumes[dstDir] = struct{}{} binds = append(binds, bind)