odavid / my-bloody-jenkins

Self Configured Jenkins Docker image based on Jenkins-LTS
MIT License
252 stars 71 forks source link

Error on OSx: failed: Permission denied: /var/run/docker.sock #200

Open yorammi opened 2 years ago

yorammi commented 2 years ago

In the last versions only (current LTS: 2.289.2-256), I've started to get the following error when a job is trying to start an agent: java.net.ConnectException: connect(..) failed: Permission denied Caused: io.netty.channel.AbstractChannel$AnnotatedConnectException: connect(..) failed: Permission denied: /var/run/docker.sock

It didn't fail on this on older versions. Posts that can help solving this: https://stackoverflow.com/questions/44999000/permission-denied-error-invoking-docker-on-mac-host-from-inside-docker-ubuntu-co https://stackoverflow.com/questions/56827949/jenkins-dial-unix-var-run-docker-sock-connect-permission-denied-macos https://stackoverflow.com/questions/47854463/docker-got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socke

odavid commented 2 years ago

Thanks @yorammi. This is a change in Docker For Mac. It is not something that can be fixed within the image, but externally.

I think the best way to mitigate it, would be to run docker:dind within the docker-compose and change the configuration of the docker plugin to point to the docker within docker...

Something like that (docker-compose):

  docker:
    image: docker:dind
    privileged: true
    volumes:
      - docker-certs:/certs
    environment:
      DOCKER_TLS_CERTDIR: ''

  jenkins:
    image: odavid/my-bloody-jenkins
  ...
    environment:
      DOCKER_HOST: tcp://docker:2375
      DOCKER_TLS_CERTDIR: ''

and within the confiugration:

clouds:
  docker-cloud:
    type: docker
    dockerHostUri: 'tcp://docker:2375'