Do not parse config.Volumes for named volumes

Fixes an issue where `VOLUME some_name:/foo` would be parsed as a named
volume, allowing access from the builder to any volume on the host.

This makes sure that named volumes must always be passed in as a bind.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff
2015-09-29 10:01:57 -04:00
parent d6e7350b96
commit 8e5bb8fdd3
2 changed files with 16 additions and 13 deletions
+13 -1
View File
@@ -5641,7 +5641,7 @@ func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *check.C) {
ctx, err := fakeContext(`
FROM busybox
ADD null /
COPY nullfile /
VOLUME nullvolume
@@ -6194,3 +6194,15 @@ func (s *DockerSuite) TestBuildBuildTimeArgDefintionWithNoEnvInjection(c *check.
c.Fatalf("unexpected number of occurrences of the arg in output: %q expected: 1", out)
}
}
func (s *DockerSuite) TestBuildNoNamedVolume(c *check.C) {
testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-v", "testname:/foo", "busybox", "sh", "-c", "touch /foo/oops")
dockerFile := `FROM busybox
VOLUME testname:/foo
RUN ls /foo/oops
`
_, err := buildImage("test", dockerFile, false)
c.Assert(err, check.NotNil, check.Commentf("image build should have failed"))
}