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

If you are getting and error running docker command as a non-root user,
dev@ubuntu:~$ docker run hello-worldError:
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.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

Solution: Provide group permission and docker.sock file permission.

Step #1: Create user-group docker and add hte user to it

sudo groupadd docker
# Example adding user "dev" to the group "docker"
sudo usermod -aG docker dev

Step #2: Provide read write permission to docker.sock file

The below will fix error, “docker: Got permission denied while trying to connect to the Docker daemon socket”
sudo chmod 666 /var/run/docker.sockOfficial documentation on post-install tasks, https://docs.docker.com/engine/install/l…stinstall/