根据docker的官方文档的描述
https://docs.docker.com/install/linux/linux-postinstall/
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 rootuser.
If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the dockergroup.
所以,只要把当前用户添加到docker用户组里面就可以了。
具体的操作步骤如下:
-
如果没有,则创建
docker用户组。$ sudo groupadd docker -
把当前用户加入docker用户组。
$ sudo usermod -aG docker $USER -
退出当前会话然后重新登录,使用户加组操作生效
-
验证是否可以在免sudo的情况下执行docker命令。
$ docker run hello-world
本文介绍如何通过将用户添加到docker组中,实现在Linux系统上无需使用sudo即可执行Docker命令的方法。具体步骤包括创建docker组、将当前用户添加到该组,并重启会话以使更改生效。
1826

被折叠的 条评论
为什么被折叠?



