Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Docker windows #5716

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/utils/DockerUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?');
}
Expand Down
7 changes: 1 addition & 6 deletions src/utils/SetupUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
33 changes: 24 additions & 9 deletions src/utils/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
}
Expand Down