Friday, April 8, 2022

[SOLVED] "dial unix /tmp/docker.sock: connect: permission denied" when running docker-compose up

Issue

I just switched to a new computer at work, and I can't figure out why I'm getting this issue. I've searched on a lot of SO threads and other websites, but nothing fixed it yet.

My OS is Fedora 29. Also I'm a noob with docker, so I'm honestly lost in all this.

So basically everytime I'm running docker-compose up, I'm getting this error:

nginx-proxy        | dockergen.1 | 2019/10/15 08:23:40 Error retrieving docker server version info: Get http://unix.sock/version: dial unix /tmp/docker.sock: connect: permission denied
nginx-proxy        | dockergen.1 | 2019/10/15 08:23:40 Error retrieving docker server info: Get http://unix.sock/info: dial unix /tmp/docker.sock: connect: permission denied
nginx-proxy        | dockergen.1 | 2019/10/15 08:23:40 Error listing containers: Get http://unix.sock/containers/json?all=1: dial unix /tmp/docker.sock: connect: permission denied
nginx-proxy        | dockergen.1 | 2019/10/15 08:23:40 Watching docker events
nginx-proxy        | dockergen.1 | 2019/10/15 08:23:40 Error retrieving docker server info: Get http://unix.sock/info: dial unix /tmp/docker.sock: connect: permission denied
nginx-proxy        | dockergen.1 | 2019/10/15 08:23:41 Docker daemon connection interrupted

docker group

I've seen a lot of people suggesting to create the docker group and add the current user in it, but it doesn't work for me, even after logging back in again and rebooting.

$ ls -l /var/run/docker.sock
srw-rw----. 1 root docker 0 Oct 15 09:58 /var/run/docker.sock
$ whoami
ave
$ groups ave
ave : ave wheel dialout docker

I've also tried sudo setfacl -m user:ave:rw /var/run/docker.sock, which didn't work either.

docker

I've tried uninstalling docker and reinstalling it, stopping the docker daemon and restarting it, docker-compose down and docker-compose up.

It doesn't matter if I'm running docker-compose up with or without sudo, the same error occurs.

docker-compose.yml

My docker-compose.yml file is like 200 lines long, so here's a part that I think is related to this issue? Tell me if more is needed.

services:
  nginx-proxy:
   build:
    context: .
    dockerfile: Dockerfile-nginx
   container_name: nginx-proxy
   ports:
    - "80:80"
   environment:
    - DEFAULT_HOST=<a host name>
   volumes:
    - /var/run/docker.sock:/tmp/docker.sock:ro
   depends_on:
    - web
    - gateway
    - processing

Solution

You need to add

privileged: true

This was merged already. To enable on your containers use:

my_service:
 privileged: true

You can check this issue.



Answered By - Adiii
Answer Checked By - Willingham (WPSolving Volunteer)