Cannot connect to the Docker daemon. Is the docker daemon running on this host?
普通用户访问已经运行的docker服务失败 原因是权限不足
from:http://www.cnblogs.com/rexzhao/p/5048004.html
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
$ ls -l /var/run/docker.sock srw-rw---- 1 root docker 0 Nov 27 05:56 /var/run/docker.sock $ chmod 666 /var/run/docker.sock
就是修改高于660的权限即可
Docker Daemon Configuration Files
This section covers Docker related files and directory permissions and ownership. Keeping the files and directories, that may contain sensitive parameters, secure is important for correct and secure functioning of Docker daemon.
Verify that docker.socket file ownership is set to root:root
If you are using Docker on a machine that uses systemd to manage services, then verify that the ‘docker.service’ file ownership and group-ownership is correctly set to ‘root’.So that when the account is switched to test user he is not able to access the docker daemon as he is not authorized to do so by root account.
$ stat -c %U:%G /usr/lib/docker | grep -v root:root
$ stat -c %U:%G /usr/lib/docker | grep root:root
root:root
If the permission is not set to root:root then it can be changed by using the following command;
$ chown root:root /usr/lib/systemd/system/docker.service
$ su test
$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
test@ubuntu:/etc/init.d$
Verify that docker.socket file permissions are set to 644 or more restrictive 660
If you are using Docker on a machine that uses systemd to manage services, then verify that the ‘docker.service’ file permissions are correctly set to ‘644’ or more restrictive.
As it can be seen below if we allocate 666 as the permission then the “test” user will be also be available to access the Docker daemon;
$ ls -l /var/run/docker.sock
srw-rw---- 1 root docker 0 Nov 27 05:56 /var/run/docker.sock
$ chmod 666 /var/run/docker.sock
$ su test
test@ubuntu:/etc/init.d$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
test@ubuntu:/etc/init.d$
As soon as we change the permission to 660 we will be able to see that the “test” user is not able to access the docker daemon.
$ chmod 660 /var/run/docker.sock
$ su test
test@ubuntu:/etc/init.d$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
test@ubuntu:/etc/init.d$ exit
exit
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!