Docker : 解决命令必须授权ROOT的办法

  • 2017-04-09
  • 287
  • 0

默认设置下,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

感谢打赏!
微信
支付宝

评论

还没有任何评论,你来说两句吧