mirror of https://github.com/docker/docs.git
Merge pull request #11538 from duglin/EmptyVolume
Check volume path to make sure its not the empty string
This commit is contained in:
commit
ded0ada9b4
|
@ -427,6 +427,10 @@ func volume(b *Builder, args []string, attributes map[string]bool, original stri
|
||||||
b.Config.Volumes = map[string]struct{}{}
|
b.Config.Volumes = map[string]struct{}{}
|
||||||
}
|
}
|
||||||
for _, v := range args {
|
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{}{}
|
b.Config.Volumes[v] = struct{}{}
|
||||||
}
|
}
|
||||||
if err := b.commit("", b.Config.Cmd, fmt.Sprintf("VOLUME %v", args)); err != nil {
|
if err := b.commit("", b.Config.Cmd, fmt.Sprintf("VOLUME %v", args)); err != nil {
|
||||||
|
|
|
@ -5540,3 +5540,19 @@ func TestBuildResourceConstraintsAreUsed(t *testing.T) {
|
||||||
|
|
||||||
logDone("build - resource constraints applied")
|
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")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue