解决Ubuntu18.04启动Docker“Got permission denied while trying to connect to the Docker daemon socket“问题

解决Ubuntu18.04启动Docker“Got permission denied while trying to connect to the Docker daemon socket“问题目录1问题描述2原因分析3解决方法4检查是否更新成功1问题描述在终端执行”dockerversion”命令,出现如下报错:”GotpermissiondeniedwhiletryingtoconnecttotheDockerdaemonsocketatunix:///var/run/docker.sock:Gethttp://…

大家好,欢迎来到IT知识分享网。

目录

1 问题描述

2 原因分析

3 解决方法

4 检查是否更新成功

5 References


1 问题描述

在终端执行”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“

解决Ubuntu18.04启动Docker“Got permission denied while trying to connect to the Docker daemon socket“问题

2 原因分析

来自docker mannual:

Manage Docker as a non-root user

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user.

If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

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

3 解决方法

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

解决Ubuntu18.04启动Docker“Got permission denied while trying to connect to the Docker daemon socket“问题

4 检查是否更新成功

再次执行”docker version”命令,发现不再出现”Got permission denied”权限报错

解决Ubuntu18.04启动Docker“Got permission denied while trying to connect to the Docker daemon socket“问题

5 References

  • https://www.cnblogs.com/informatics/p/8276172.html

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/12515.html

(0)
上一篇 2024-03-07 19:00
下一篇 2024-03-13 19:45

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信