Search code examples
intellij-ideadocker-composepermission-denied

Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? (Details: [13] Permission denied) in IntelliJ


I'm trying to run all services from docker-compose.yaml in IntelliJ IDEA, but I get the message inside of the services panel that says

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (Details: [13] Permission denied)

and the service is running

$ service docker status

● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2023-10-06 19:18:29 CEST; 19h ago
  TriggeredBy: ● docker.socket
        Docs: https://docs.docker.com
     Main PID: 2968617 (dockerd)
        Tasks: 22
     Memory: 925.9M
        CPU: 24.084s
     CGroup: /system.slice/docker.service
              └─2968617 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

and running it from terminal doesn't work as well

$ docker compose -f docker-compose.yaml up -d

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: 
Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.config-hash%22%3Atrue%2C%22com.docker.compose.project%3Dmongodb%22%3Atrue%7D%7D": 
dial unix /var/run/docker.sock: connect: permission denied

And after installing docker-compose and using that I get the following error:

$ docker-compose -f docker-compose.yaml up -d

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    ...
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  ...
  File "/usr/lib/python3/dist-packages/docker/transport/unixconn.py", line 30, in connect
    sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  ...
requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 33, in <module>
    sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
    command_func()
  ...
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 221, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))

Solution

  • I suggest you to follow the Offical linux post installation guide:

    sudo groupadd docker
    sudo usermod -aG docker $USER
    

    Then log out and log back in so that your group membership is re-evaluated.

    PS: if you don't do that, you can use docker only as root.