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

相关推荐
下次再写14 小时前
微服务架构实战:Spring Boot + Spring Cloud 从入门到精通
java·spring boot·spring cloud·微服务架构·服务注册与发现·分布式系统·api网关
蜀道山老天师16 小时前
云原生监控入门:监控基础概念 + SLI/SLO/SLA 详解 + Prometheus 从零安装配置
linux·运维·云原生·prometheus
运维老郭18 小时前
K8S 容器独占 CPU(CPU 绑核)最佳实践,解锁极致性能所需的 3 个核心条件及其代价
运维·云原生·kubernetes
掘根21 小时前
【微服务即时通讯】登录注册界面设计
微服务·云原生·架构
非情剑1 天前
Tlog实现微服务日志追踪
微服务·云原生·架构
小小仙。1 天前
IT自学第四十一天(微服务)
微服务·云原生·架构
志栋智能1 天前
超自动化巡检:敏捷运维体系中的重要一环
运维·服务器·网络·云原生·容器·kubernetes·自动化
ZOE^V11 天前
springcloud笔记
笔记·spring cloud·github
东北甜妹1 天前
K8s job /cronjob 和 Networkpolicy
云原生·容器·kubernetes
hyunbar1 天前
ZooKeeper 未授权访问漏洞:你做的 ACL 加固可能只是“假动作”
分布式·zookeeper·云原生