Browse code

Windows Daemon should respect DOCKER_TMPDIR

Signed-off-by: Ryan Simmen <ryan.simmen@gmail.com>

Ryan Simmen authored on 2017/10/04 06:47:55
Showing 1 changed files
... ...
@@ -555,7 +555,17 @@ func NewDaemon(config *config.Config, registryService registry.Service, containe
555 555
 	if err != nil {
556 556
 		return nil, fmt.Errorf("Unable to get the full path to the TempDir (%s): %s", tmp, err)
557 557
 	}
558
-	os.Setenv("TMPDIR", realTmp)
558
+	if runtime.GOOS == "windows" {
559
+		if _, err := os.Stat(realTmp); err != nil && os.IsNotExist(err) {
560
+			if err := system.MkdirAll(realTmp, 0700, ""); err != nil {
561
+				return nil, fmt.Errorf("Unable to create the TempDir (%s): %s", realTmp, err)
562
+			}
563
+		}
564
+		os.Setenv("TEMP", realTmp)
565
+		os.Setenv("TMP", realTmp)
566
+	} else {
567
+		os.Setenv("TMPDIR", realTmp)
568
+	}
559 569
 
560 570
 	d := &Daemon{
561 571
 		configStore: config,