Trouble shooting docker - permission denied

webduvet

webduvet

Posted on May 22, 2023

Trouble shooting docker - permission denied

After installation or just after a an OS update or some package update docker engine starts to complain about insufficient permissions.
Particularly it complains about permission to access /var/run/docker.sock

docker ps
// permission denied message
Enter fullscreen mode Exit fullscreen mode
$> ls -la /var/run/docker.sock
Enter fullscreen mode Exit fullscreen mode

The output should show root:docker as {ownder}:{group}.
Run also

ls -l /lib/systemd/system/docker.socket
Enter fullscreen mode Exit fullscreen mode

The output should show root:docker as {ownder}:{group}.
If it shows root:root there is a problem

sudo chgrp docker /lib/systemd/system/docker.socket
Enter fullscreen mode Exit fullscreen mode

Check the following:

groups
Enter fullscreen mode Exit fullscreen mode

Current user should be member of these groups: docker, kvm.
if the docker group doesn't exist add it

sudo groupadd docker
Enter fullscreen mode Exit fullscreen mode

If the new group is added or the group is there but current user is not a member, add it.

sudo usermod -aG kvm $USER
Enter fullscreen mode Exit fullscreen mode

The current user now should be visible in group file /etc/group
or when running

getent group
Enter fullscreen mode Exit fullscreen mode

or simply

groups
Enter fullscreen mode Exit fullscreen mode

If not try running:

sudo su $USER -c groups
Enter fullscreen mode Exit fullscreen mode

If the list of groups contain kvm and docker you need to log out and log back in or somehow restart system-auth.
After that it should work or there is further problem unrelated to the above.

verify

docker ps
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
webduvet
webduvet

Posted on May 22, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related