(普通用户)Cannot connect to the Docker daemon at unix:///var/run/docker.sock.

报错:
复制代码
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

#大概像以下的报错内容
MernyPierreMBP:~ merny24$ docker info
Client:
 Version:    26.1.4
 Context:    default
 Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
MernyPierreMBP:~ merny24$

环境:

在做某项配置时发现docker不能使用,检查了daemon.json文件是没有问题的。因为是另一个运维做的环境,就只有普通用户,docker的权限给不到

方法一

sudo groupadd docker #添加用户组

sudo gpasswd -a username docker #将当前用户添加至用户组

newgrp docker #更新用户组

#没效果再重启下试试

方法二
复制代码
vim /lib/systemd/system/docker.service                  # Ubuntu的路径;
/usr/lib/systemd/system/docker.service                  # CentOS 的路径为;
修改文件内容:
# ExecStart=/usr/bin/dockerd -H fd://
ExecStart=/usr/bin/dockerd

重新启动docker服务就行
复制代码
service dockerd  restar
方法三

#这个方法不确定,因为我的环境里没有root,就是普通用户,但给了权限状态就恢复了

chmod 777 /run/docker.sock

systemctl restart docker

相关推荐
櫻花44 分钟前
微服务各大组件总结
微服务·云原生·架构
-大头.1 小时前
微服务架构深度演进与实践指南
微服务·云原生·架构
Henry Zhu1232 小时前
VPP中FIB(转发信息库)和VRF(虚拟路由转发)详解:从设计理念到实际应用
网络·计算机网络·云原生·云计算·智能路由器
wniuniu_2 小时前
ceph入门
windows·ceph·eureka
Li_7695322 小时前
Spring Cloud —— SkyWalking (一)
spring·spring cloud·skywalking
Ttang232 小时前
【SpringCloud1】从单体架构到分布式系统架构
分布式·spring cloud·架构
摇滚侠4 小时前
2025最新 SpringCloud 教程,熔断规则-熔断策略-异常比例,笔记45
redis·笔记·spring cloud
摇滚侠4 小时前
2025最新 SpringCloud 教程,Seat-原理-四种事务模式,总结,笔记72,笔记73
笔记·spring·spring cloud·架构
GOTXX4 小时前
openEuler AI与云原生 构建高效智能的数字基础设施底座
人工智能·云原生
百万彩票中奖候选人4 小时前
迁移 Docker 存储目录
java·docker·eureka