Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows docker: permission denied /var/run/docker.sock

When I try to run filebeat with autodiscover I get the following error:

Exiting: error in autodiscover provider settings: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.22/containers/json?limit=0: dial unix /var/run/docker.sock: connect: permission denied

I exposed the daemon on tcp://localhost:2375 from docker settings.

I checked that my user is member of "docker-users" group.

docker-compose.yml:

filebeat:
    image: store/elastic/filebeat:7.3.0
    volumes:
      - ./config/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
      - /var/lib/docker/containers/:/var/lib/docker/containers/:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
like image 268
cdalxndr Avatar asked Aug 30 '19 10:08

cdalxndr


People also ask

How do I fix docker permission is denied?

Similar to running a docker command without the sudo command, a stopped Docker Engine triggers the permission denied error. How do you fix the error? By restarting your Docker engine. Run the systemctl command below to confirm the Docker Engine's status ( status docker ) and if it's running.

What is var run docker sock?

sock is basically the Unix socket the Docker daemon listens on by default. It is also a tool used to communicate with the Docker daemon from within a container. Sometimes, containers need to bind mount the /var/run/docker. sock file.

How do I fix docker got permission denied while trying to connect to the docker daemon socket?

Fix 1: Run all the docker commands with sudo If you have sudo access on your system, you may run each docker command with sudo and you won't see this 'Got permission denied while trying to connect to the Docker daemon socket' anymore.


1 Answers

Adding user: root to docker-compose.yml fixes socket access:

filebeat:
    image: store/elastic/filebeat:7.3.0
    volumes:
      - ./config/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
      - /var/lib/docker/containers/:/var/lib/docker/containers/:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    user: root
like image 114
cdalxndr Avatar answered Oct 05 '22 03:10

cdalxndr