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..105c74a44 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(); } diff --git a/src/utils/Util.js b/src/utils/Util.js index 7c13bb8b8..813d3b9ff 100644 --- a/src/utils/Util.js +++ b/src/utils/Util.js @@ -4,6 +4,7 @@ import fs from 'fs'; import path from 'path'; import crypto from 'crypto'; import electron from 'electron'; +import request from 'request'; const remote = electron.remote; const dialog = remote.dialog; const app = remote.app; @@ -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 = request.get({ + url: `http://docker.local:2375/version` + }, (error, response) => { + if (error !== null || 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; + } } } }