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

相关推荐
const_qiu11 小时前
微服务测试策略:端到端质量保障
微服务·云原生·架构
朱包林12 小时前
k8s-Pod基础管理,标签管理,rc控制器及重启策略实战
linux·运维·云原生·容器·kubernetes·云计算
returnthem12 小时前
最新版 Kubernetes 集群搭建教程(kubeadm 方式)
云原生·容器·kubernetes
白花生12 小时前
k8s集群内的ollama pod持久化调用本地大模型
云原生·容器·kubernetes
姚不倒12 小时前
从 Docker 到 Kubernetes:容器编排核心原理与网络实践
运维·云原生·容器·kubernetes
splage13 小时前
SpringBoot 与 SpringCloud的版本对应详细版
spring boot·后端·spring cloud
不是株13 小时前
SpringCloud
后端·spring·spring cloud
ShineWinsu14 小时前
开源项目Git贡献全流程拆解
eureka
wenlonglanying17 小时前
springboot与springcloud对应版本
java·spring boot·spring cloud
@土豆18 小时前
kubernetes场景基于limits内存百分比实现横向Pod自动扩缩容(HPA)
云原生·容器·kubernetes