普通用户权限运行docker
官方文档权限介绍
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 `root` user.
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 docker
group.
普通用户执行权限添加
- 创建
docker
用户组sudo groupadd docker
- 添加你想用普通用户权限的用户名到
docker
用户组sudo usermod -aG docker $USER
- 系统重启后就可以使用普通用户权限执行
docker
, 如果不想重启,可以使用下面的命令更新并激活组权限newgrp docker
- 验证设置是否成功
docker run hello-world
如果出现下面错误提示,建议重启电脑:WARNING: Error loading config file: /home/user/.docker/config.json - stat /home/user/.docker/config.json: permission denied
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: