(20201209已解决)docker命令必须加sudo

46 篇文章 1 订阅
  • 问题描述

    直接运行docker 命令出现:

    Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://~images/json: dial unix /var/run/docker.sock: connect: permission denied

    sudo docker 执行命令才可以.

  • 解决方案

    If you want to run docker as non-root user then you need to add it to the docker group.

    sudo groupadd docker
    sudo usermod -aG docker $USER
    newgrp docker
    

    On Linux, when you run any docker command, the docker binary will try to connect to /var/run/docker.sock. As indicated by its .sock extension, this file is a Unix Domain Socket - basically, a way so multiple processes can communicate on the local computer (also called an IPC mechanism.)

    IPC, Inter-Process Communication

    In the case of Docker, the main reason for using the socket is that any user belonging to the docker group can connect to the socket while the Docker daemon itself can run as root.

  • References

  1. How to fix docker: Got permission denied issue
  2. Solving Docker permission denied while trying to connect to the Docker daemon socket
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值