code: func GetAuthInfo(indexServer string) (string, string, error) {
  	// official docker registry
  	if indexServer == defaultIndexURL {
  		indexServer = defaultIndexURLAuth
  	}
  	dockerCfgPath := path.Join(getHomeDir(), ".docker", dockercfgFileName)
  	if _, err := os.Stat(dockerCfgPath); err == nil {
  		j, err := ioutil.ReadFile(dockerCfgPath)
  		if err != nil {
  			return "", "", err
  		}
  		var dockerAuth types.DockerConfigFile
  		if err := json.Unmarshal(j, &dockerAuth); err != nil {
  			return "", "", err
  		}
  		// try the normal case
  		if c, ok := dockerAuth.AuthConfigs[indexServer]; ok {
  			return decodeDockerAuth(c.Auth)
  		}
  	} else if os.IsNotExist(err) {
  		oldDockerCfgPath := path.Join(getHomeDir(), dockercfgFileNameOld)
  		if _, err := os.Stat(oldDockerCfgPath); err != nil {
  			return "", "", nil //missing file is not an error
  		}
  		j, err := ioutil.ReadFile(oldDockerCfgPath)
  		if err != nil {
  			return "", "", err
  		}
  		var dockerAuthOld map[string]types.DockerAuthConfigOld
  		if err := json.Unmarshal(j, &dockerAuthOld); err != nil {
  			return "", "", err
  		}
  		if c, ok := dockerAuthOld[indexServer]; ok {
  			return decodeDockerAuth(c.Auth)
  		}
  	} else {
  		// if file is there but we can't stat it for any reason other
  		// than it doesn't exist then stop
  		return "", "", fmt.Errorf("%s - %v", dockerCfgPath, err)
  	}
  	return "", "", nil
  }
docs: // GetDockercfgAuth reads a ~/.dockercfg file and returns the username and password
  // of the given docker index server.