Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 0905da8

Browse files
zappy-shuthaJeztah
authored andcommitted
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> (cherry picked from commit 1a5dafb31eed7a44115f13595b54eaf109c4f388) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 239ac23799b7a15751d74616ef8357b40f3b759b Component: engine
1 parent 34c442a commit 0905da8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

components/engine/client/request.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp
178178
// this is localised - for example in French the error would be
179179
// `open //./pipe/docker_engine: Le fichier spécifié est introuvable.`
180180
if strings.Contains(err.Error(), `open //./pipe/docker_engine`) {
181-
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.")
181+
// Checks if client is running with elevated privileges
182+
if f, elevatedErr := os.Open("\\\\.\\PHYSICALDRIVE0"); elevatedErr == nil {
183+
err = errors.Wrap(err, "In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.")
184+
} else {
185+
f.Close()
186+
err = errors.Wrap(err, "This error may indicate that the docker daemon is not running.")
187+
}
182188
}
183189

184190
return serverResp, errors.Wrap(err, "error during connect")

0 commit comments

Comments
 (0)