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

相关推荐
乐观的Terry4 小时前
3、数据库设计与领域实体
java·数据库·spring boot·spring cloud·ai编程
阿里云云原生6 小时前
从 ReAct 到 Harness:AgentScope 2.0 如何用“工程化”定义分布式智能体开发范式?
云原生·agent
nece00111 小时前
Kubernetes v1.36.0 + Ubuntu24.04 + containerd 2.x WordPress 完整部署文档
云原生·容器·kubernetes
ai_coder_ai13 小时前
编写自动化脚本,在自己后端服务中使用云原生Baas服务进行网络相关操作
运维·云原生·自动化
吃饱了得干活13 小时前
Spring Cloud Gateway限流:从Redis到Sentinel的三种方案
后端·spring cloud
Demon_Hao2 天前
Spring Boot 4、JDK 25 与 GraalVM:Java 云原生进化,能否撼动 Go 的地位?
java·spring boot·云原生
江畔柳前堤2 天前
GO01-Go 语言与主流编程语言深度对比
开发语言·人工智能·后端·微服务·云原生·golang·go
探索云原生2 天前
终于搞懂 Kueue:5 个核心对象一次讲透
linux·docker·ai·云原生·kubernetes
月落星还在2 天前
Spring MVC 与 Spring Boot:从“手动挡”到“自动驾驶”的进化论,兼谈前后端分离的哲学
spring boot·spring·云原生·mvc