From 462cab80a7b714a1af3bfb008a3bf5e4e8b5d976 Mon Sep 17 00:00:00 2001 From: French Ben Date: Tue, 10 May 2016 10:52:08 -0700 Subject: [PATCH] Added pipe back in Signed-off-by: French Ben --- src/utils/DockerUtil.js | 10 +++++++++- src/utils/SetupUtil.js | 9 ++------- src/utils/Util.js | 33 ++++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/utils/DockerUtil.js b/src/utils/DockerUtil.js index 376a2cf60..7c6bd2fd5 100644 --- a/src/utils/DockerUtil.js +++ b/src/utils/DockerUtil.js @@ -34,7 +34,15 @@ var DockerUtil = { if (ip.indexOf('local') !== -1) { try { - this.client = new dockerode({socketPath: '/var/run/docker.sock'}); + if (util.isWindows()) { + this.client = new dockerode({ + protocol: 'http', + host: ip, + port: 2375 + }); + } else { + this.client = new dockerode({socketPath: '/var/run/docker.sock'}); + } } catch (error) { throw new Error('Cannot connect to the Docker daemon. Is the daemon running?'); } diff --git a/src/utils/SetupUtil.js b/src/utils/SetupUtil.js index b6932a8f7..d8c7c9ad3 100644 --- a/src/utils/SetupUtil.js +++ b/src/utils/SetupUtil.js @@ -69,12 +69,7 @@ export default { while (true) { try { if (util.isNative()) { - let stats = fs.statSync('/var/run/docker.sock'); - if (stats.isSocket()) { - await this.nativeSetup(); - } else { - throw new Error('File found is not a socket'); - } + await this.nativeSetup(); } else { await this.nonNativeSetup(); } @@ -96,7 +91,7 @@ export default { while (true) { try { router.get().transitionTo('setup'); - docker.setup(util.isLinux() ? 'localhost':'docker.local'); + docker.setup(util.isWindows() ? 'docker.local':'localhost'); setupServerActions.started({started: true}); this.simulateProgress(20); return docker.version(); diff --git a/src/utils/Util.js b/src/utils/Util.js index 7c13bb8b8..3545237e1 100644 --- a/src/utils/Util.js +++ b/src/utils/Util.js @@ -3,6 +3,7 @@ import Promise from 'bluebird'; import fs from 'fs'; import path from 'path'; import crypto from 'crypto'; +import http from 'http'; import electron from 'electron'; const remote = electron.remote; const dialog = remote.dialog; @@ -40,15 +41,29 @@ module.exports = { }, isNative: function () { if (this.native === null) { - try { - // Check if file exists - fs.statSync('/var/run/docker.sock'); - this.native = true; - } catch (e) { - if (this.isLinux()) { - this.native = true; - } else { - this.native = false; + if (this.isWindows()) { + this.native = http.get({ + url: `http:////./pipe/docker_engine/v1.23/version` + }, (response) => { + if (response.statusCode !== 200 ) { + return false; + } else { + return true; + } + }); + } else { + try { + // Check if file exists + let stats = fs.statSync('/var/run/docker.sock'); + if (stats.isSocket()) { + this.native = true; + } + } catch (e) { + if (this.isLinux()) { + this.native = true; + } else { + this.native = false; + } } } }