Problem
When I ran just docker version
command on Ubuntu 20.04 LTS, it throws an error like below. But it was fine when I used sudo docker version
.
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
Solution
- Create a docker group if it does not exist
sudo groupadd docker
- Add the current logged in user to the docker group
sudo usermod -aG docker $USER
- Run the below command or Logout and login again and run.
newgrp docker
- Run the below command to check if it’ works
docker run hello-world
- If it’s not working reboot your machine
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.