Docker : 解决命令必须授权ROOT的办法
默认设置下,docker的所有的命令必须加上个sudo提升权限才能执行,否则都会报错.
大致意思是,使用socket连接daemon进程的时候被拒绝,原因是拒绝访问。
该问题的官方解释如下:
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 access it with sudo. For this reason, docker daemon always runs as the root user.
To avoid having to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.
解决办法:
1.创建docker组:sudo groupadd docker
2.将当前用户加入docker组:sudo gpasswd -a ${USER} docker
3.重启服务:sudo service docker restart
4.刷新Docker成员:newgrp - docker