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

相关推荐
jieyucx3 分钟前
站在云原生高并发天花板:拆解 Go 语言 GMP 模型与 I/O 多路复用的神级配合
开发语言·云原生·golang
张忠琳21 分钟前
【client-go v0.36.1】tools/cache 深度分析(上篇)— 模块定位、整体结构、接口与依赖关系
云原生·kubernetes·cache·informer·client-go
张忠琳28 分钟前
【client-go v0.36.1】(Reflector Part 1)Reflector 超深度分析 — 模块定位、整体结构、接口与依赖
云原生·kubernetes·informer·client-go·reflector
小江的记录本40 分钟前
【Spring全家桶】Spring Cloud 2023.0.x:配置中心:Nacos Config、Apollo(附《思维导图》+《面试高频考点清单》)
java·spring boot·后端·python·spring·spring cloud·面试
Demon1_Coder1 小时前
Day4-微服务-Seata
微服务·云原生·架构
huipeng9261 小时前
企业级微服务开发实战(三):公共模块设计与统一规范封装
java·spring boot·spring cloud·微服务·架构·系统架构·php
张忠琳1 小时前
【client-go v0.36.1】client-go v0.36.1 系统级架构分析(下篇)
云原生·kubernetes·client-go
IT策士2 小时前
第50篇 k8s之系列总结 + 项目演示与后续扩展
云原生·容器·kubernetes
卧室小白2 小时前
K8S-Pod的生命周期与调度
云原生·容器·kubernetes
张忠琳12 小时前
【SR-IOV cni】(Part 4) SR-IOV Network Device Plugin 3.11.0 — 超深度架构分析
网络·云原生·kubernetes·cni·sriov