首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Docker daemon socket权限不足

Docker daemon socket权限不足

作者头像
py3study
发布于 2020-04-17 16:17:44
发布于 2020-04-17 16:17:44
2.7K0
举报
文章被收录于专栏:python3python3

一、概述

普通用户执行命令:docker ps报错,具体信息如下:

代码语言:javascript
复制
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.38/containers/create: dial unix /var/run/docker.sock: connect: permission denied.

出现上面问题是因为:

Manage Docker as a non-root user 即:管理Docker的不是root用户

原文表述:

代码语言:javascript
复制
The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user.
If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

即:docker进程使用Unix Socket而不是TCP端口。而默认情况下,Unix socket属于root用户,需要root权限才能访问。

二、解决方案

代码语言:javascript
复制
方案一:使用sudo获取管理员权限,运行docker命令
方案二:添加docker group组,将用户添加进去

环境说明

操作系统:centos 7.6

docker版本:19.03.5

由于采用的是jumpserver方式登录,开发人员使用的是develop账号。

docker安装之后,默认会创建组docker,因此不需要再创建了。

执行命令

使用root账号登录目标服务器

代码语言:javascript
复制
#将登陆用户develop加入到docker用户组中
gpasswd -a develop docker
#更新用户组
newgrp docker

切换到develop用户进行测试

代码语言:javascript
复制
su develop
docker ps

输出正常,则表示成功了。

本文参考链接:

https://www.jianshu.com/p/a0cf03605c42

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/04/16 ,如有侵权请联系 cloudcommunity@tencent.com 删除
目录
  • 一、概述
  • 二、解决方案
    • 环境说明
    • 执行命令
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档