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

相关推荐
江畔何人初4 小时前
iptables 和 IPVS 代理模式 Service 的区别
linux·运维·服务器·网络·云原生·kubernetes·代理模式
小猿姐14 小时前
当KubeBlocks遇上国产数据库之Kingbase:让信创数据库“飞得更高”
运维·数据库·云原生
烛之武15 小时前
SpringCloud基础(上)
笔记·spring·spring cloud
会飞的大可16 小时前
WMS系统演进——从单体到微服务
微服务·云原生·架构
bjzhang7517 小时前
SpringCloud——国产化改造,项目对接 TongWeb 嵌入版
后端·spring·spring cloud
无名-CODING18 小时前
SpringCloud 网关与熔断:Gateway + Sentinel 快速入门
spring cloud·gateway·sentinel
cyber_两只龙宝18 小时前
【Docker】Dockerfile构建镜像实验全流程详解
linux·运维·docker·云原生
沐风清扬18 小时前
RuoYi-Cloud微服务架构核心技术揭秘
微服务·云原生·架构
无名-CODING19 小时前
SpringCloud 服务注册与发现:Nacos 零基础入门实战
后端·spring·spring cloud
笨手笨脚の19 小时前
k8s 中的一些小知识
云原生·容器·kubernetes