1
0
mirror of https://github.com/moby/moby.git synced 2025-07-30 18:23:29 +03:00

Initialize volumes when container is created

Fixes #8942
Current behavior is that volumes aren't initialized until start.
Volumes still need to be initialized on start since VolumesFrom and
Binds can be passed in as part of HostConfig on start, however anything
that's already been initialized will just be skipped as is the current
behavior.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff
2014-11-11 11:17:33 -05:00
parent 2a517fe103
commit 7107898d5c
3 changed files with 29 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"os"
"os/exec"
"testing"
"time"
@ -125,3 +126,21 @@ func TestCreateEchoStdout(t *testing.T) {
logDone("create - echo test123")
}
func TestCreateVolumesCreated(t *testing.T) {
name := "test_create_volume"
cmd(t, "create", "--name", name, "-v", "/foo", "busybox")
dir, err := inspectFieldMap(name, "Volumes", "/foo")
if err != nil {
t.Fatalf("Error getting volume host path: %q", err)
}
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
t.Fatalf("Volume was not created")
}
if err != nil {
t.Fatalf("Error statting volume host path: %q", err)
}
logDone("create - volumes are created")
}