1. 檢查系統中是否存在docker用戶組,若是沒有則手動添加
# sudo cat /etc/group |grep docker
# sudo grouped -g 999 docker
# -g 999爲用戶組,也能夠不指定。其實用yum安裝好docker,會自動建立docker用戶組
2. 爲用戶組docker添加用戶
# sudo gpasswd -a [user] docker
3. 重啓docker-deamon
# sudo systemctl restart docker
4. 執行docker命令時若是發生如下錯誤,則修改/var/run/docker.sock權限
# sudo chmod a+rw /var/run/docker.sock
[jenkins@xyz ~]$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.27/containers/json: dial unix /var/run/docker.sock: connect: permission denied