1

on the Ubuntu 18.04 system I have cloned a project and to run it needs gradle but at running the gradle command gradle swiplRun I get the following error

Task :dockerRun FAILED docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create?name=swiprolog: dial unix /var/run/docker.sock: connect: permission denied. See 'docker run --help'.

Task :dockerRunStatus FAILED 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.39/containers/swiprolog/json: dial unix /var/run/docker.sock: connect: permission denied

FAILURE: Build completed with 2 failures.

to solve I tried

$ sudo groupadd docker
$ sudo usermod -a -G docker myname  
"and once with"
$ sudo gpasswd -a myname docker

so I can run docker commands without sudo, but the same error also ./gradlew --stop and logout/login and reboot did not work too.

is it because of Docker or Gradle?

1 Answer 1

0

I had the same error

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.24/containers/json?all=1": dial unix /var/run/docker.sock: connect: permission denied

when running docker ps

What helped was:

sudo gpasswd -a $USER docker
newgrp docker

See Stack Overflow Docker-compose up : Error while fetching server API version: ('Connection aborted.', ConnectionRefusedError(61, 'Connection refused'))

Another way:

sudo usermod -aG docker $USER
sg docker -c "bash" 

It does the same as above, no need to run both two-liners.

If you checked all of these commands once, and you still get the error, you know that it is not a Docker, but a Gradle problem. It would mean that Gradle does not get the needed sudo rights at one point. That could happen from a local and not system-wide python installation on the container, just to name one example.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .