Tuesday, September 5, 2017

Do you get a "Got permission denied while trying to connect to the Docker daemon socket" even after successful docker login?

Do you get a warning during the login to docker hub via terminal even after providing correct credentials?

Is the warning looks like below?

docker login
Warning: failed to get default registry endpoint from daemon (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.30/info: dial unix /var/run/docker.sock: connect: permission denied). Using system default: https://index.docker.io/v1/
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.

Username: ushanib
Password:

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.30/auth: dial unix /var/run/docker.sock: connect: permission denied

This is because you have to run the command as the super user as below:

sudo docker login