(普通用户)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

相关推荐
☞遠航☜8 小时前
搭建基础的springcloud alibaba项目练习
后端·spring·spring cloud
RingWu12 小时前
微服务架构-全链路追踪
微服务·云原生·架构
Elastic 中国社区官方博客16 小时前
Kubernetes 可观测性:用于更安全 EKS 故障排查的 MCP 专家 agents
大数据·elasticsearch·搜索引擎·云原生·容器·kubernetes·全文检索
环流_18 小时前
Nacos VS Eureka
云原生·eureka
天涯明月199318 小时前
AEnvironment深度研究报告
人工智能·后端·云原生
Devin~Y19 小时前
大厂Java面试实录:Spring Boot/Cloud + Redis + Kafka + JVM + RAG(Spring AI)三轮追问(小Y翻车版)
java·jvm·spring boot·redis·spring cloud·kafka·mybatis
接着奏乐接着舞1 天前
spring cloud知识点
后端·spring·spring cloud
SPC的存折1 天前
19-2、K8s 三种 QoS 等级 & 与 Resources(requests_limits)的核心关联
云原生·容器·kubernetes
SPC的存折1 天前
1、K8S-组件介绍
云原生·容器·kubernetes
狼与自由2 天前
微服务网关演化
微服务·云原生·架构