mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Improve readability of Windows connect error
Improve the readability of the connection error displayed to the user on Windows when running docker commands fails by checking if the client is privileged. If so then display the actual error wrapped in a generic error "This error may indicate that the docker daemon is not running." If not that display the actual error wrapped in a more specific error: "In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect." Signed-off-by: Nick Adcock <nick.adcock@docker.com>
This commit is contained in:
parent
ecaf0b479f
commit
1a5dafb31e
1 changed files with 7 additions and 1 deletions
|
@ -178,7 +178,13 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp
|
||||||
// this is localised - for example in French the error would be
|
// this is localised - for example in French the error would be
|
||||||
// `open //./pipe/docker_engine: Le fichier spécifié est introuvable.`
|
// `open //./pipe/docker_engine: Le fichier spécifié est introuvable.`
|
||||||
if strings.Contains(err.Error(), `open //./pipe/docker_engine`) {
|
if strings.Contains(err.Error(), `open //./pipe/docker_engine`) {
|
||||||
err = errors.New(err.Error() + " In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.")
|
// Checks if client is running with elevated privileges
|
||||||
|
if f, elevatedErr := os.Open("\\\\.\\PHYSICALDRIVE0"); elevatedErr == nil {
|
||||||
|
err = errors.Wrap(err, "In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.")
|
||||||
|
} else {
|
||||||
|
f.Close()
|
||||||
|
err = errors.Wrap(err, "This error may indicate that the docker daemon is not running.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return serverResp, errors.Wrap(err, "error during connect")
|
return serverResp, errors.Wrap(err, "error during connect")
|
||||||
|
|
Loading…
Reference in a new issue