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

Commit

Permalink
Merge pull request #1667 from docker/add-pipe
Browse files Browse the repository at this point in the history
Added pipe back in
  • Loading branch information
FrenchBen committed May 10, 2016
2 parents 8df589c + 462cab8 commit e0bcf4c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
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
9 changes: 2 additions & 7 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 All @@ -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();
Expand Down
33 changes: 24 additions & 9 deletions src/utils/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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 = 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;
}
}
}
}
Expand Down

0 comments on commit e0bcf4c

Please sign in to comment.