Docker免sudo权限本地build脚本

默认docker.sock是root:docker的权限

直接执行docker build会报错如下:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.30/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=hello-http&target=&ulimits=null: dial unix /var/run/docker.sock: connect: permission denied

参考自:http://www.jianshu.com/p/95e397570896

# 将自己添加到docker组中
sudo groupadd docker
sudo gpasswd -a ${USER} docker
# 重启后重新load下权限
sudo service docker restart
newgrp - docker

 

Leave a Reply

Your email address will not be published. Required fields are marked *