浏览代码

Use USERPROFILE path on Windows as home directory

Signed-off-by: Ahmet Alp Balkan <ahmetb@microsoft.com>
Ahmet Alp Balkan 10 年之前
父节点
当前提交
d4dbb70832
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      docker/flags.go

+ 9 - 1
docker/flags.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"os"
 	"path/filepath"
+	"runtime"
 
 	"github.com/docker/docker/opts"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -16,10 +17,17 @@ var (
 
 func init() {
 	if dockerCertPath == "" {
-		dockerCertPath = filepath.Join(os.Getenv("HOME"), ".docker")
+		dockerCertPath = filepath.Join(getHomeDir(), ".docker")
 	}
 }
 
+func getHomeDir() string {
+	if runtime.GOOS == "windows" {
+		return os.Getenv("USERPROFILE")
+	}
+	return os.Getenv("HOME")
+}
+
 var (
 	flVersion     = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
 	flDaemon      = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")