dockerode-options
v0.2.1
Published
Parse docker options out of DOCKER_HOST or Docker in Docker setup
Downloads
3,246
Maintainers
Readme
dockerode-options
Can both parse string based options (like 127.0.0.1:4243) for dockerode and find sensible defaults for connecting to docker.
Usage
With a string
var dockerOpts = require('dockerode-options');
var Docker = require('dockerode');
// DOCKER_HOST = '127.0.0.1:4243'
var options = dockerOpts(process.env.DOCKER_HOST);
// => { host: 'http://127.0.0.1', port: 4243 }
// these can now be used to start dockerode
var docker = new Docker(options);
With no options
var dockerOpts = require('dockerode-options');
var options = dockerOpts();
// => { socketPath: '/var/run/docker.sock' }
With DOCKER_HOST environment variable set
var dockerOpts = require('dockerode-options');
process.env.DOCKER_HOST = '127.0.0.1:60022';
var options = dockerOpts();
// => { host: '127.0.0.1', port: 60022 };
With DOCKER_CERT_PATH environment variable set
var dockerOpts = require('dockerode-options');
process.env.DOCKER_CERT_PATH = '/home/certs';
var options = dockerOpts();
// => { ca: <contents of /home/certs/ca.pem>, cert: <contents of /home/certs/cert.pem>, key: <contents of /home/certs/key.pem> };