mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Move root symlink check to engine.New
Since commit c91c365
, when starting the docker daemon without an
existing /var/lib/docker directory, it fails with:
2013/12/18 23:39:36 Unable to canonicalize root (%!s(*string=0xc210077c80)): lstat /var/lib/docker: no such file or directory
Move the symlink checking code to engine.New after the root dir has been
created.
This commit is contained in:
parent
681b40c801
commit
94821a3353
2 changed files with 16 additions and 14 deletions
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/dotcloud/docker/utils"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -71,19 +70,6 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
// Docker makes some assumptions about the "absoluteness" of flRoot
|
||||
// ... so let's make sure it has no symlinks
|
||||
if p, err := filepath.Abs(*flRoot); err != nil {
|
||||
log.Fatalf("Unable to get absolute root (%s): %s", flRoot, err)
|
||||
} else {
|
||||
*flRoot = p
|
||||
}
|
||||
if p, err := filepath.EvalSymlinks(*flRoot); err != nil {
|
||||
log.Fatalf("Unable to canonicalize root (%s): %s", flRoot, err)
|
||||
} else {
|
||||
*flRoot = p
|
||||
}
|
||||
|
||||
eng, err := engine.New(*flRoot)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
@ -79,9 +80,24 @@ func New(root string) (*Engine, error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(root, 0700); err != nil && !os.IsExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Docker makes some assumptions about the "absoluteness" of root
|
||||
// ... so let's make sure it has no symlinks
|
||||
if p, err := filepath.Abs(root); err != nil {
|
||||
log.Fatalf("Unable to get absolute root (%s): %s", root, err)
|
||||
} else {
|
||||
root = p
|
||||
}
|
||||
if p, err := filepath.EvalSymlinks(root); err != nil {
|
||||
log.Fatalf("Unable to canonicalize root (%s): %s", root, err)
|
||||
} else {
|
||||
root = p
|
||||
}
|
||||
|
||||
eng := &Engine{
|
||||
root: root,
|
||||
handlers: make(map[string]Handler),
|
||||
|
|
Loading…
Reference in a new issue