I have been trying to call docker from my Node.js application, and to do so I am using node-docker-api as described in the npm module documentation https://github.com/AgustinCB/docker-api. To test if I am able to interact with docker from Node.js I am running a small sample application given as a example in the documentation. But I am getting error as { Error: connect ENOENT /var/run/docker.sock. The complete error message is shown below
dockerOperations.js:
'use strict';
const {Docker} = require('node-docker-api');
var Q = require('q');
var service = {}
service.runDockerCommand = runDockerCommand;
function runDockerCommand() {
console.log('inside runDockerCommand');
var deferred = Q.defer();
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
console.log(docker);
docker.container.create({
Image: 'ubuntu',
name: 'test'
})
.then(container => container.start())
.then(container => container.stop())
.then(container => container.restart())
.then(container => container.delete({ force: true }))
.catch(error => console.log(error));
return deferred.promise;
}
Error
{ Error: connect ENOENT /var/run/docker.sock
at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1170:14)
errno: 'ENOENT', code: 'ENOENT', syscall: 'connect', address: '/var/run/docker.sock' }
/var/run/docker.sock
exist on the host? What OS is your host machine? – Allopatricnpipe:////./pipe/docker_engine
– Allopatric