diff --git a/build/utils/docker.js b/build/utils/docker.js index 5c53eeba..f10b3327 100644 --- a/build/utils/docker.js +++ b/build/utils/docker.js @@ -68,8 +68,9 @@ exports.appendOptions = function(opts) { }; exports.generateConnectOpts = generateConnectOpts = function(opts) { - var Promise, _, fs; + var Promise, _, buildDockerodeOpts, fs; Promise = require('bluebird'); + buildDockerodeOpts = require('dockerode-options'); fs = require('mz/fs'); _ = require('lodash'); return Promise["try"](function() { @@ -82,6 +83,8 @@ exports.generateConnectOpts = generateConnectOpts = function(opts) { connectOpts.port = opts.dockerPort || 2376; } else if ((opts.docker != null) && (opts.dockerHost != null)) { throw new Error("Both a local docker socket and docker host have been provided. Don't know how to continue."); + } else if (process.env.DOCKER_HOST) { + connectOpts = buildDockerodeOpts(process.env.DOCKER_HOST); } else { connectOpts.socketPath = '/var/run/docker.sock'; } diff --git a/lib/utils/docker.coffee b/lib/utils/docker.coffee index 73e53654..340e207d 100644 --- a/lib/utils/docker.coffee +++ b/lib/utils/docker.coffee @@ -86,6 +86,7 @@ exports.appendOptions = (opts) -> exports.generateConnectOpts = generateConnectOpts = (opts) -> Promise = require('bluebird') + buildDockerodeOpts = require('dockerode-options') fs = require('mz/fs') _ = require('lodash') @@ -103,8 +104,11 @@ exports.generateConnectOpts = generateConnectOpts = (opts) -> else if opts.docker? and opts.dockerHost? # Both provided, no obvious way to continue throw new Error("Both a local docker socket and docker host have been provided. Don't know how to continue.") + else if process.env.DOCKER_HOST + # If no explicit options are provided, use the env + connectOpts = buildDockerodeOpts(process.env.DOCKER_HOST) else - # None provided, assume default docker local socket + # No options anywhere, assume default docker local socket connectOpts.socketPath = '/var/run/docker.sock' # Now need to check if the user wants to connect over TLS diff --git a/package.json b/package.json index 0915ae4d..c029557f 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "docker-qemu-transpose": "^0.2.2", "docker-toolbelt": "^1.3.3", "dockerode": "^2.5.0", + "dockerode-options": "^0.2.1", "drivelist": "^5.0.22", "etcher-image-write": "^9.0.3", "global-tunnel-ng": "github:zvin/global-tunnel#dont-proxy-connections-to-file-sockets",