[Solved] Docker Error: got permission denied while trying to connect to the docker daemon socket at…

Problem Description:
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.40/version: Dial UNIX/var/run/docker.sock: Connect: permission denied
error reason:
docker process uses UNIX socket instead of TCP port. By default, UNIX socket belongs to the root user and needs root permission to access it
solution:

sudo groupadd docker     #Add the docker user group
sudo gpasswd -a $USER docker #Add the logged-in user to the docker user group
newgrp docker #Update the user group
docker ps #Test that the docker command works properly with sudo


Read More: