一、概述

普通用户执行命令: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. ES模块化的导入和导出

    目录 环境准备 模块化 export.import export import import * as export default import 和 require 的区别 参考 环境准备 三个文件 ...

  2. Codeforces Round #547 (Div. 3) D. Colored Boots (贪心,模拟)

    题意:有两个字符串,两个字符串中的相同字符可以相互匹配,\(?\)可以和任意字符匹配,输出最大匹配的字符数量和它们分别两个字符串中的位置. 题解:很容易贪心,我们先遍历第一个字符串,然后在第二个字符串 ...

  3. 洛谷P1144-最短路计数-最短路变形

    洛谷P1144-最短路计数 题目描述: 给出一个\(N\)个顶点\(M\)条边的无向无权图,顶点编号为\(1-N\).问从顶点\(1\)开始,到其他每个点的最短路有几条. 思路: \(Dijkstra ...

  4. CF1463-A. Dungeon

    题意: 你面前有三个怪物,他们分别有a, b, c点血量.现在你可以指定一个怪物,用大炮向他们射击,之后该怪物就会掉一滴血.每七次射击就会使得炮弹威力加强一次,即第7, 14, 21次射击的时候炮弹威 ...

  5. 包机制和javadoc

    包机制 一般用公司域名倒置作为包名: eg com.baidu.www 可以在src里自己鼠标右键建立包,包内可以存放代码, 包的路径必须在最上面, eg:package com.kuang; (自动 ...

  6. Linux-关于Bash

    目录 关于Bash Bash是什么? Bash的一些特性 关于Bash Bash是什么? Bash是一个命令处理器,通常运行于文本窗口中,并能执行用户直接输入的命令. Bash还能从文件中读取命令,这 ...

  7. codeforces 5D

    D. Follow Traffic Rules time limit per test 1 second memory limit per test 64 megabytes input standa ...

  8. HDU 4675 GCD of Sequence(莫比乌斯反演 + 打表注意事项)题解

    题意: 给出\(M\)和\(a数组\),询问每一个\(d\in[1,M]\),有多少组数组满足:正好修改\(k\)个\(a\)数组里的数使得和原来不同,并且要\(\leq M\),并且\(gcd(a_ ...

  9. HDU 6623 Minimal Power of Prime(思维)题解

    题意: 已知任意大于\(1\)的整数\(a = p_1^{q_1}p_2^{q_2} \cdots p_k^{q_k}\),现给出\(a \in [2,1e18]\),求\(min\{q_i\},q ...

  10. In_array()函数弱比较

    0x01 定义 (PHP 4, PHP 5, PHP 7) in_array - 检查数组中是否存在某个值 说明 in_array ( mixed $needle , array $haystack ...