(20201209已解决)docker命令必须加sudo
发布日期:2021-05-07 14:23:31 浏览次数:29 分类:精选文章

本文共 901 字,大约阅读时间需要 3 分钟。

  • 问题描述

    直接运行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 dockersudo usermod -aG docker $USERnewgrp 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

上一篇:理解ip addr命令下面各个子项目eth0的意思
下一篇:(20201208已解决)WSL启动docker失败

发表评论

最新留言

不错!
[***.144.177.141]2025年03月24日 07时12分32秒