1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Automatically create non-existent bind-mounted directories on the host

Fixes #1279.

Docker-DCO-1.1-Signed-off-by: Maxime Petazzoni <max@signalfuse.com> (github: mpetazzoni)
This commit is contained in:
Maxime Petazzoni 2013-11-11 13:29:56 -08:00
parent b417f79c00
commit 3e96f46b30

View file

@ -1909,10 +1909,13 @@ func (srv *Server) ContainerStart(job *engine.Job) engine.Status {
// ensure the source exists on the host // ensure the source exists on the host
_, err := os.Stat(source) _, err := os.Stat(source)
if err != nil && os.IsNotExist(err) { if err != nil && os.IsNotExist(err) {
job.Errorf("Invalid bind mount '%s' : source doesn't exist", bind) err = os.MkdirAll(source, 0755)
if err != nil {
job.Errorf("Could not create local directory '%s' for bind mount: %s!", source, err.Error())
return engine.StatusErr return engine.StatusErr
} }
} }
}
// Register any links from the host config before starting the container // Register any links from the host config before starting the container
if err := srv.RegisterLinks(container, &hostConfig); err != nil { if err := srv.RegisterLinks(container, &hostConfig); err != nil {
job.Error(err) job.Error(err)