Files
cloudron-box/src/docker.js
T

24 lines
585 B
JavaScript
Raw Normal View History

'use strict';
2015-10-19 11:08:23 -07:00
var Docker = require('dockerode');
2015-10-19 11:08:23 -07:00
var gConnection = connectionInstance();
exports = module.exports = gConnection;
function connectionInstance() {
var docker;
2015-07-24 01:42:28 -07:00
if (process.env.BOX_ENV === 'test') {
// test code runs a docker proxy on this port
docker = new Docker({ host: 'http://localhost', port: 5687 });
2015-10-19 11:08:23 -07:00
// proxy code uses this to route to the real docker
docker.options = { socketPath: '/var/run/docker.sock' };
} else {
2015-10-19 11:08:23 -07:00
docker = new Docker({ socketPath: '/var/run/docker.sock' });
}
return docker;
}