From b851133fb18c2e413d3d9de5589c33a5930110ba Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Mon, 7 Oct 2019 12:10:00 -0400 Subject: [PATCH] Support npipe:// in DOCKER_HOST In Windows, `DOCKER_HOST` can contain things like `npipe:////./pipe/docker_engine` or `npipe:////./pipe/docker_wsl`. Currently it isn't possible to use `DOCKER_HOST` = `npipe:////./pipe/docker_wsl` to use the WSL2 Docker engine; rather, you must pass in `socketPath` to dockerode. If you try using the above for `DOCKER_HOST` you'll get an error. --- lib/modem.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/modem.js b/lib/modem.js index b26e139..25e4b3a 100644 --- a/lib/modem.js +++ b/lib/modem.js @@ -25,6 +25,10 @@ var defaultOpts = function() { // Strip off unix://, fall back to default of /var/run/docker.sock if // unix:// was passed without a path opts.socketPath = process.env.DOCKER_HOST.substring(7) || '/var/run/docker.sock'; + } else if (process.env.DOCKER_HOST.indexOf('npipe://') === 0) { + // Strip off npipe://, fall back to default of //./pipe/docker_engine if + // npipe:// was passed without a path + opts.socketPath = process.env.DOCKER_HOST.substring(8) || '//./pipe/docker_engine'; } else { var hostStr = process.env.DOCKER_HOST; if(hostStr.indexOf('\/\/') < 0) {