In this article, we will find the solution for the error “docker: Got permission denied while trying to connect to the Docker daemon socket”.
The above error received when run with non-root user. If run the docker command like below, we haven’t received the erro.
sudo docker run helloworld
If we run without sudo or non-root user received the subjected error.
So, solution is we have add user docker group. If not exists, we have to create it and add the docker to docker group.
1. lets verify group docker is there are or not by running below command.
getent group docker
If group is not there, create it by running sudo groupadd docker.
2. Now add user to docker group.
sudo usermod -aG docker $USER
3. Log in to the new docker group (to avoid having to log out / log in again; but if not enough, try to reboot):
newgrp docker
4. Now, run the docker command without root or sudo user.
docker run hello-world
Still if you receive error, we have to reboot the host machine.