'After executing following code of dockerode npm getting error "connect EACCES /var/run/docker.sock" on ubuntu 14.04
I am executing following code to get list of all container using npm dockerode on Ubuntu 14.04 machine. Docker container are running properly.
var Docker = require('dockerode');
var docker = new Docker({socketPath: '/var/run/docker.sock'});
docker.listContainers({all: true}, function(err, containers) {
console.log('err ' + err);
console.log('ALL: ' + containers);
});
But getting
Error connect EACCES /var/run/docker.sock
thanks in advance.
Solution 1:[1]
For security-wise, I go pro for GreatDharmatma and Pankaj Kumar.
If you want to skip the logging back and access instantly you can assign rw permission to other users
sudo chmod o+rw /var/run/docker.sock
Solution 2:[2]
Without changing the socket rights maybe just creating a new user node for nodejs then add him to the docker group
sudo useradd -g node docker
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Amartis Glady |
| Solution 2 | Minaro |
