5
votes

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
Did you try opening new shell? It might be that group membership doesn't apply to your current shell.Igor Nikolaev
@IgorNikolaev I doubt what you mean by opening a new shell? doesn't the rebooting system count as if a new shell is opened?Amir-Mousavi
Rebooting should help, I must have missed that you tried to login/logoff. How did you install Docker? I remember installing Docker recently on Ubuntu and it required custom package repository to be added. I think we followed this instruction (digitalocean.com/community/tutorials/…) and it worked after that.Igor Nikolaev
Also probably verify that your user had docker group assigned after all. It didn't work for us for some reason at first, only after we installed Docker according to the documentation mentioned above.Igor Nikolaev

1 Answers

2
votes

Try restarting docker once

sudo systemctl restart docker

Then this one to finally solve the problem .

sudo chmod 666 /var/run/docker.sock

Now try running

docker run hello-world

it will pull the image from docker hub repository and that means your docker is now running properly.