Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.so
阅读原文时间:2023年09月03日阅读:1

在安装Docker以后,执行命令出现错误。

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.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied

解决办法

  1. 添加当前用户到docker组

    sudo gpasswd -a $USER docker

  2. 更新dokcer组

    newgrp docker

  3. 重启docker(可选,如何执行完以上命令仍无法解决问题)

    sudo systemctl restart docker