diff --git a/src/moby/build.go b/src/moby/build.go index 56892ae18..415c08c5e 100644 --- a/src/moby/build.go +++ b/src/moby/build.go @@ -142,7 +142,7 @@ func outputImage(image *Image, section string, prefix string, m Moby, idMap map[ // Build performs the actual build process func Build(m Moby, w io.Writer, pull bool, tp string) error { if MobyDir == "" { - return fmt.Errorf("MobyDir for temporary storage not set") + MobyDir = defaultMobyConfigDir() } iw := tar.NewWriter(w) diff --git a/src/moby/util.go b/src/moby/util.go index b262e0066..56afefb88 100644 --- a/src/moby/util.go +++ b/src/moby/util.go @@ -1,6 +1,16 @@ package moby +import ( + "path/filepath" +) + var ( - // MobyDir is the location of the cache directory which should be set by the caller + // MobyDir is the location of the cache directory, defaults to ~/.moby MobyDir string ) + +func defaultMobyConfigDir() string { + mobyDefaultDir := ".moby" + home := homeDir() + return filepath.Join(home, mobyDefaultDir) +}