From 8071bf396747d3ad01db504a417b75fe7a52608a Mon Sep 17 00:00:00 2001
From: Doug Davis <dug@us.ibm.com>
Date: Fri, 20 Mar 2015 21:39:49 -0700
Subject: [PATCH] Check volume path to make sure its not the empty string

With this Dockerfile
```
FROM ubuntu
ENV ABC=""
VOLUME $ABC
```

It builds ok but then at run time I get this error:

FATA[0002] Error response from daemon: Cannot start container 8902b4a7aaf5c4e4b11a38070d392db465fa97ad88c91c8b38dda5ab8149ccac: [8] System error: no such file or directory

Because the Volume config shows "" as the path.  This PR checks for "" as
the path and stops it at build time.

Signed-off-by: Doug Davis <dug@us.ibm.com>
---
 builder/dispatchers.go                   |  4 ++++
 integration-cli/docker_cli_build_test.go | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/builder/dispatchers.go b/builder/dispatchers.go
index 3cb3a9fb3a..4d21a75eb5 100644
--- a/builder/dispatchers.go
+++ b/builder/dispatchers.go
@@ -427,6 +427,10 @@ func volume(b *Builder, args []string, attributes map[string]bool, original stri
 		b.Config.Volumes = map[string]struct{}{}
 	}
 	for _, v := range args {
+		v = strings.TrimSpace(v)
+		if v == "" {
+			return fmt.Errorf("Volume specified can not be an empty string")
+		}
 		b.Config.Volumes[v] = struct{}{}
 	}
 	if err := b.commit("", b.Config.Cmd, fmt.Sprintf("VOLUME %v", args)); err != nil {
diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go
index c83759d75a..81bdef028c 100644
--- a/integration-cli/docker_cli_build_test.go
+++ b/integration-cli/docker_cli_build_test.go
@@ -5408,3 +5408,19 @@ func TestBuildResourceConstraintsAreUsed(t *testing.T) {
 
 	logDone("build - resource constraints applied")
 }
+
+func TestBuildEmptyStringVolume(t *testing.T) {
+	name := "testbuildemptystringvolume"
+	defer deleteImages(name)
+
+	_, err := buildImage(name, `
+  FROM busybox
+  ENV foo=""
+  VOLUME $foo
+  `, false)
+	if err == nil {
+		t.Fatal("Should have failed to build")
+	}
+
+	logDone("build - empty string volume")
+}