zoukankan      html  css  js  c++  java
  • docker 知识汇总2-免sudo

    问题:当以普通用户身份去使用docker images时,出现以下错误:

    [lzx@pp test]$ docker images
    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.39/images/json: dial unix /var/run/docker.sock: connect: permission denied
    [lzx@pp test]$ ls -l /var/run/docker.sock
    srw-rw----. 1 root docker 0 8月  13 20:44 /var/run/docker.sock

    可以看到当前用户没有读写权限,需要吧当前用户添加到有读写权限的docker组中

    步骤:

    1. 查看有无docker 组cat /etc/group |grep docker, 没有的话建一个组sudo groupadd docker

    2.将当前用户添加到docker组(一般只需这关键一步):sudo usermod -aG docker $USER #或 sudo gpasswd -a ${USER} docker

    3.重启docker 服务:sudo service docker restart

    4. 切换当前会话到新 group 或者重启 X 会话(如果是ssh会话退出重连):newgrp - docker

    注意:最后一步是必须的,否则因为 groups 命令获取到的是缓存的组信息,刚添加的组信息未能生效,所以 docker images 执行时同样有错。

    参考链接:https://www.cnblogs.com/mafeng/p/8683914.html

  • 相关阅读:
    HDU1026 Ignatius and the Princess I
    luogu_1865 A % B Problem
    luogu_1092 虫食算
    luogu_1111 修复公路
    luogu_1265 公路修建
    luogu_2330 [SCOI2005]繁忙的都市
    luogu_1613 跑路
    luogu_3386 【模板】二分图匹配
    luogu_3388 【模板】割点(割顶)
    luogu_2327 扫雷
  • 原文地址:https://www.cnblogs.com/i-shu/p/11348548.html
Copyright © 2011-2022 走看看