github.com/zhouyu0/docker-note@v0.0.0-20190722021225-b8d3825084db/cli/config/configdir.go (about)

     1  package config // import "github.com/docker/docker/cli/config"
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  
     7  	"github.com/docker/docker/pkg/homedir"
     8  )
     9  
    10  var (
    11  	configDir     = os.Getenv("DOCKER_CONFIG")
    12  	configFileDir = ".docker"
    13  )
    14  
    15  // Dir returns the path to the configuration directory as specified by the DOCKER_CONFIG environment variable.
    16  // TODO: this was copied from cli/config/configfile and should be removed once cmd/dockerd moves
    17  func Dir() string {
    18  	return configDir
    19  }
    20  
    21  func init() {
    22  	if configDir == "" {
    23  		configDir = filepath.Join(homedir.Get(), configFileDir)
    24  	}
    25  }