Docker Rancher - Permission Denied when using docker from WSL - docker

I have installed Docker Rancher on Windows 10 with dockerd option and WSL on true for my current WSL distribution (Ubuntu).
When i try to use docker in WSL2, I had the following error:
fpapi#xxx:~$ docker ps
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": dial unix /var/run/docker.sock: connect: permission denied
The command works fine in the cmd shell.
Which kind of permission I'm missing?

The issue is that Docker Rancher installer do not create the docker group.
Use the following commands:
sudo addgroup --system docker
sudo adduser $USER docker
newgrp docker
# And something needs to be done so $USER always runs in group `docker` on the `Ubuntu` WSL
sudo chown root:docker /var/run/docker.sock
sudo chmod g+w /var/run/docker.sock
thanks to https://github.com/rancher-sandbox/rancher-desktop/issues/1156#issuecomment-1017042882

Related

Installing portainner on ubunto server permission denied

So I just installed docker and installed home assistant on docker everything is working but now I want to install PORTAINER starting with this command
docker volume create portainer_data
**And when I press enter it gives me this message get permission denied while trying to connect to the docker daemon socket at unt x:///ver/run/docker and at last it says connect: permission denied
**
What should I do ? Iam new to ubunto and have no experience
I don't know what to do
Try this
sudo groupadd docker
and
sudo usermod -aG docker ${USER}
Also check all docker group users
grep /etc/group -e "docker"

docker commands without sudo user even after adding groupadd

even after adding sudo groupadd docker and sudo usermod -aG docker $USER , i cannot use docker commands without sudo
`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": dial unix /var/run/docker.sock: connect: permission denied.
So I had to use "sudo". How can I get ignored sudo in docker commands
Create a group called docker and add yourself to it using the commands
sudo groupadd docker
sudo usermod -aG docker $USER
Then you can run docker commands without using sudo.
Try restarting docker.
sudo groupadd docker
sudo usermod -aG docker $USER
sudo service docker restart
Giving more access to this file solves the problem, but it is not recommended it gives every local process and user unrestricted root access over the host!
chmod 777 /var/run/docker.sock
then you don't need to use sudo but it's not recommended.

Preparation failed: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

Trying to transform a project in gitlab to docker image. The gitlab is selfhosted. This is the error I get:
Running with gitlab-runner 13.12.0 (7a6612da)
on test -KnwQXuT
Preparing the "docker" executor
ERROR: Failed to remove network for build
ERROR: Preparation 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.25/info: dial
unix /var/run/docker.sock: connect: permission denied (docker.go:858:0s)
I added a runner,registered it, created a gitlab-ci.yml with docker template which I left unmodified. As solutions I tried chmod 666 /var/run/docker.sock before and after adding the runner but it did not work. I also added sudo before running and registering the docker runner but still no success. I found another option to add my docker user to group docker but all my users are in the docker group. The docker runner is run as a docker image. I did not know what to do...Please help. I`m am trying for about 10 days with no success... Thanks in advance
Create docker group if not exist : sudo groupadd docker
Add user to docker group : sudo usermod -aG docker ${USER}
Change docker.sock to new permission : sudo chmod 666 /var/run/docker.sock
Finally restart docker daemon service : sudo systemctl restart docker
When you use gitlab self-hosted runner, by default, it creates a user named gitlab-runner. You need to assign the permissions to it.
sudo usermod -aG docker gitlab-runner
this will assign the correct permissions to the gitlab-runner and should pull the docker images on that VM.

docker: Got permission denied while trying to connect to the Docker daemon socket

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?
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.

Got permission denied while trying to connect to the Docker daemon socket while executing docker build

I am trying to build docker image through Jenkins installed on Ubuntu 16.04.
However, getting the error stated :
"Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post".
Any suggestions are welcomed...Thanks!!!
Run the following commands
sudo usermod -a -G docker $USER
newgrp docker
Then run your command :-)

Resources