configdir.go 682 B

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