Jenkins Docker容器无法访问docker.sock

我用docker-compose和这个configuration部署了标准的Jenkins Docker镜像:

deployer: image: jenkins volumes: - "/mnt/jenkins:/var/jenkins_home" - "/var/run/docker.sock:/var/run/docker.sock" ports: - "2375:2375" - "8080:8080" - "50000:50000" 

在阅读了大量的SO问题后,我testing了使用gpasswd -a ${USER} docker docker exec jenkins_deployer echo ${USER}将Root添加到docker用户组,并validationContainer中的用户是root用docker exec jenkins_deployer echo ${USER}

当我尝试添加Docker访问里面的“Docker URL = unix:///var/run/docker.sock”时,我得到错误消息“ org.newsclub.net.unix.AFUNIXSocketException:权限被拒绝(套接字: /run/docker.sock)

我怎样才能让jenkins访问docker.sock来自动部署Docker容器?