解决 ERROR:Docker Got permission denied while trying to connect to the Docker daemon socket at unix

解决 ERROR:Docker Got permission denied while trying to connect to the Docker daemon socket at unix

在终端执行"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.26/images/json: dial unix /var/run/docker.sock: connect: permission denied“

docker进程使用 Unix Socket 而不是 TCP 端口。而默认情况下,Unix socket 属于 root 用户,因此需要 root权限 才能访问

解决方法


sudo groupadd docker          #添加docker用户组
sudo gpasswd -a $XXX docker   #检测当前用户是否已经在docker用户组中,其中XXX为用户名,例如我的,liangll
sudo gpasswd -a $USER docker  #将当前用户添加至docker用户组
newgrp docker                 #更新docker用户组

或者
sudo gpasswd -a ${USER} docker
sudo su
exit
newgrp docker

https://blog.csdn.net/xiangxianghehe/article/details/80897769
https://blog.csdn.net/liangllhahaha/article/details/92077065

posted @ 2023-04-28 16:36  michaelchengjl  阅读(924)  评论(0编辑  收藏  举报