docker.sock权限被拒绝 [英] docker.sock permission denied
问题描述
当我尝试运行简单的docker命令,例如:
When I try to run simple docker commands like:
$ docker ps -a
我收到一条错误消息:
获得权限被拒绝.../var/run/docker.sock:连接:权限被拒绝
Got permission denied ... /var/run/docker.sock: connect: permission denied
当我检查权限时
$ ls -al /var/run/
我看到这一行:
srw-rw---- root docker docker.sock
因此,我遵循许多论坛的建议,并将本地用户添加到docker组:
So, I follow an advice from many forums and add local user to docker group:
$ sudo usermod -aG docker $USER
但这无济于事.我仍然收到非常相同的错误消息.我该如何解决?
But it does not help. I still get the very same error message. How can I fix it?
推荐答案
对于那些不熟悉shell的人,命令:
For those new to the shell, the command:
$ sudo usermod -aG docker $USER
需要在shell中定义$USER
.默认情况下,该位置通常位于此位置,但是在某些外壳中,您可能需要将该值设置为登录ID.
needs to have $USER
defined in your shell. This is often there by default, but you may need to set the value to your login id in some shells.
更改用户组不会更改用户已打开的现有登录名,终端和外壳程序.为避免再次执行登录,您只需运行:
Changing the groups of a user does not change existing logins, terminals, and shells that a user has open. To avoid performing a login again, you can simply run:
$ newgrp docker
获得对当前shell中该组的访问权限.
to get access to that group in your current shell.
完成此操作后,用户将在服务器上有效地具有root用户访问权限,因此仅对受不受限制的sudo访问权限信任的用户执行此操作.
Once you have done this, the user effectively has root access on the server, so only do this for users that are trusted with unrestricted sudo access.
这篇关于docker.sock权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!