We have received below error when tried to run image in docker.
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'.
Reason:
We have tried to run docker image with non-root privileges.
Solution:
We have to non-root privilege user to docker with below commands.
Syntax:
sudo usermod -aG docker $USER
Example:
sudo usermod -aG docker r2schools
On Linux, run the following command to activate the changes to groups:
newgrp docker
Now, try to execute the docker image with non-root privilege user which we have added in the above step.