summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorNick Adcock <nick.adcock@docker.com>2019-07-22 10:07:50 +0100
committerNick Adcock <nick.adcock@docker.com>2019-08-20 12:07:14 +0100
commit1a5dafb31eed7a44115f13595b54eaf109c4f388 (patch)
tree254f2914e4c17cc2b00152d6241565667eec5630 /client
parentecaf0b479fa7a80b211cc8906905a7f9a2f87e6d (diff)
downloaddocker-1a5dafb31eed7a44115f13595b54eaf109c4f388.tar.gz
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>
Diffstat (limited to 'client')
-rw-r--r--client/request.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/client/request.go b/client/request.go
index 3078335e2c..2610338da6 100644
--- a/client/request.go
+++ b/client/request.go
@@ -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
// `open //./pipe/docker_engine: Le fichier spécifié est introuvable.`
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")