Browse code

Windows: Hint to run client elevated

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2016/10/15 02:14:43
Showing 1 changed files
... ...
@@ -143,6 +143,20 @@ func (cli *Client) sendClientRequest(ctx context.Context, method, path string, q
143 143
 			}
144 144
 		}
145 145
 
146
+		// Although there's not a strongly typed error for this in go-winio,
147
+		// lots of people are using the default configuration for the docker
148
+		// daemon on Windows where the daemon is listening on a named pipe
149
+		// `//./pipe/docker_engine, and the client must be running elevated.
150
+		// Give users a clue rather than the not-overly useful message
151
+		// such as `error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.25/info:
152
+		// open //./pipe/docker_engine: The system cannot find the file specified.`.
153
+		// Note we can't string compare "The system cannot find the file specified" as
154
+		// this is localised - for example in French the error would be
155
+		// `open //./pipe/docker_engine: Le fichier spécifié est introuvable.`
156
+		if strings.Contains(err.Error(), `open //./pipe/docker_engine`) {
157
+			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.")
158
+		}
159
+
146 160
 		return serverResp, errors.Wrap(err, "error during connect")
147 161
 	}
148 162