[英]Jenkins with docker-compose got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
I want to setup some dockerized tool on my vps.我想在我的 vps 上设置一些 dockerized 工具。 That includes jenkins and a proxy.
这包括詹金斯和代理。 Everything is building fine but when using the docker agent in jenkins I run into this error :
一切都很好,但是在 jenkins 中使用 docker 代理时,我遇到了这个错误:
+ docker build -t 286802dd81862d714cfc6a90c84d30200546eaa9 -f Dockerfile .
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.39/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&session=srtihghhshf8z9c2lkdnvr8dm&shmsize=0&t=286802dd81862d714cfc6a90c84d30200546eaa9&target=&ulimits=null&version=1: dial unix /var/run/docker.sock: connect: permission denied
script returned exit code 1
here is what my docker-compose looks like :这是我的 docker-compose 的样子:
services:
proxy:
image: jwilder/nginx-proxy
networks:
- mynetwork
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
restart: always
mariadb:
image: bitnami/mariadb:latest
...
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
...
jenkins:
image: jenkinsci/blueocean:latest
networks:
- mynetwork
environment:
- VIRTUAL_HOST=jenkins.mydomain.com
- VIRTUAL_PORT=8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./jenkins-data:/var/jenkins_home
- ./jenkins-docker-certs:/certs/client:ro
- ./jenkins-home:/home
restart: always
networks:
mynetwork:
driver: bridge
Am I missing something in my compose file ?我的撰写文件中是否缺少某些内容?
So far I have tried adding the jenkins user to the docker and root group on the running docker instance but with no success.到目前为止,我已经尝试将 jenkins 用户添加到正在运行的 docker 实例上的 docker 和 root 组,但没有成功。
I found a way to fix this.我找到了解决这个问题的方法。 I simply specified the root user in the docker-compose.yml like this :
我只是在 docker-compose.yml 中指定了 root 用户,如下所示:
jenkins:
image: jenkinsci/blueocean:latest
user: root
networks:
- mynetwork
environment:
- VIRTUAL_HOST=jenkins.mydomain.com
- VIRTUAL_PORT=8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./jenkins-data:/var/jenkins_home
- ./jenkins-docker-certs:/certs/client:ro
- ./jenkins-home:/home
restart: always
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.