From 3e96f46b30340f8468a7bac8c159b610a2309821 Mon Sep 17 00:00:00 2001 From: Maxime Petazzoni Date: Mon, 11 Nov 2013 13:29:56 -0800 Subject: [PATCH] Automatically create non-existent bind-mounted directories on the host Fixes #1279. Docker-DCO-1.1-Signed-off-by: Maxime Petazzoni (github: mpetazzoni) --- server.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 331c596411..db26441bc1 100644 --- a/server.go +++ b/server.go @@ -1909,8 +1909,11 @@ func (srv *Server) ContainerStart(job *engine.Job) engine.Status { // ensure the source exists on the host _, err := os.Stat(source) if err != nil && os.IsNotExist(err) { - job.Errorf("Invalid bind mount '%s' : source doesn't exist", bind) - return engine.StatusErr + 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 + } } } // Register any links from the host config before starting the container