Merge pull request #1667 from docker/add-pipe

Added pipe back in
This commit is contained in:
French Ben
2016-05-10 12:22:50 -07:00
3 changed files with 35 additions and 17 deletions

View File

@@ -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?');
}

View File

@@ -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();

View File

@@ -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;
}
}
}
}