github.com/wozhu6104/docker@v20.10.10+incompatible/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  // If DOCKER_CONFIG is unset, Dir returns ~/.docker .
    17  // Dir ignores XDG_CONFIG_HOME (same as the docker client).
    18  // TODO: this was copied from cli/config/configfile and should be removed once cmd/dockerd moves
    19  func Dir() string {
    20  	return configDir
    21  }
    22  
    23  func init() {
    24  	if configDir == "" {
    25  		configDir = filepath.Join(homedir.Get(), configFileDir)
    26  	}
    27  }