mirror of https://github.com/docker/docs.git
Merge pull request #9089 from cpuguy83/8942_create_volumes_on_create
Initialize volumes when container is created
This commit is contained in:
commit
67fda33197
|
@ -100,6 +100,13 @@ func (daemon *Daemon) Create(config *runconfig.Config, hostConfig *runconfig.Hos
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := container.Mount(); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
defer container.Unmount()
|
||||||
|
if err := container.prepareVolumes(); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
if err := container.ToDisk(); err != nil {
|
if err := container.ToDisk(); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,9 @@ a list of daemon labels (`Labels`).
|
||||||
**New!**
|
**New!**
|
||||||
You can set the new container's MAC address explicitly.
|
You can set the new container's MAC address explicitly.
|
||||||
|
|
||||||
|
**New!**
|
||||||
|
Volumes are now initialized when the container is created.
|
||||||
|
|
||||||
`POST /containers/(id)/start`
|
`POST /containers/(id)/start`
|
||||||
|
|
||||||
**New!**
|
**New!**
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -125,3 +126,21 @@ func TestCreateEchoStdout(t *testing.T) {
|
||||||
|
|
||||||
logDone("create - echo test123")
|
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")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue