一、概述

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

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用户

原文表述:

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权限才能访问。

二、解决方案

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

环境说明

操作系统:centos 7.6

docker版本:19.03.5

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

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

执行命令

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

#将登陆用户develop加入到docker用户组中
gpasswd -a develop docker
#更新用户组
newgrp docker

切换到develop用户进行测试

su develop
docker ps

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

本文参考链接:

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

Docker daemon socket权限不足的更多相关文章

  1. Got permission denied while trying to connect to the Docker daemon socket at

    添加新用户后执行docker命令由于没权限出现以下报错: ”Got permission denied while trying to connect to the Docker daemon soc ...

  2. Docker permission denied while trying to connect to the Docker daemon socket

    Problem jenkins执行docker打包的时候报错,说没有权限 docker build -t docker.ryan-miao.com/com.demo:f1aa23e --build-a ...

  3. Got permission denied while trying to connect to the Docker daemon socket at unix

    拉取Dockerimages时错误信息如下: [master@localhost ~]$ docker pull redis Using default tag: latest Got permiss ...

  4. 启动docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

    启动docker提示: docker: Got permission denied while trying to connect to the Docker daemon socket at uni ...

  5. 解决Docker运行命令时提示"Got permission denied while trying to connect to the Docker daemon socket"类情况

    Docker安装命令: 解决Docker运行命令时提示"Got permission denied while trying to connect to the Docker daemon ...

  6. Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/images/json: dial unix /var/run/docker.sock: conne

    使用docker报如下错误信息: Got permission denied while trying to connect to the Docker daemon socket at unix:/ ...

  7. docker Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post

    利用docker构建时,报错 + docker pull maven:3-alpine Got permission denied while trying to connect to the Doc ...

  8. [问题解决]Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

    写了一个脚本读取docker日志,发生报错:Got permission denied while trying to connect to the Docker daemon socket at u ...

  9. 【解决】Got permission denied while trying to connect to the Docker daemon socket at......dial unix /var/run/docker.sock: permission denied

    >>> 问题:搭建Portainer时,选择本地连接报错? >>>分析: 根据报错信息可知是权限问题. 可能原因一:使用了非root用户启用或连接docker &g ...

随机推荐

  1. hdu3635 Dragon Balls

    Problem Description Five hundred years later, the number of dragon balls will increase unexpectedly, ...

  2. hdu3669 Cross the Wall

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 327680/327680 K (Java/Others) Total Submissi ...

  3. Spring Boot @Enable*注解源码解析及自定义@Enable*

      Spring Boot 一个重要的特点就是自动配置,约定大于配置,几乎所有组件使用其本身约定好的默认配置就可以使用,大大减轻配置的麻烦.其实现自动配置一个方式就是使用@Enable*注解,见其名知 ...

  4. K8S(10)配置中心实战-configmap资源

    k8s配置中心实战-configmap资源 目录 k8s配置中心实战-configmap资源 0 configmap前置说明 0.1.1 configmap和secret 0.1.2 怎么使用conf ...

  5. 爬虫——urllib.request包

    一.引用包 import urllib.request 二.常用方法 (1)urllib.request.urlretrieve(网址,本地文件存储地址):直接下载网页到本地 urllib.reque ...

  6. hash table

    Hash Table,叫做哈希表,也叫做散列表.概念:通过某种对应关系h,使得每一个元素和储存位置一一对应.这种对应关系称为哈希函数.它最大的优点就是插入.搜索和删除得很快(O(1)).碰撞(Coll ...

  7. 洛谷p1886滑动窗口最大最小值 双单调队列

    #include <iostream> #include <cstdio> using namespace std; int n,k,a[1000007],q1[2000007 ...

  8. μC/OS-III---I笔记8---事件标志

    当任务需要同步时可以使用信号量.A任务给B任务发送消息后B任务才能继续运行.如果需要A任务给任务B传递数据的时候就可以采用消息队列.但对于繁杂任务的同步,比如多个时间发生以后执行一个事件,或者是C任务 ...

  9. 钉钉 & URL Scheme & Universal Link & Deep Link

    钉钉 & URL Scheme & Universal Link & Deep Link DD link https://www.cnblogs.com/xgqfrms/p/1 ...

  10. Python Quiz & Python Exercise

    Python Quiz & Python Exercise https://www.w3schools.com/quiztest/quiztest.asp?qtest=PYTHON https ...