0

I have installed bitnami/jenkins on my Managed Kubernetes cluster.

I need to run Jenkins job which will build docker image and push to docker repository. When I do this on a Jenkins instance in a simple container on host, I simply mount docker.sock as volume to the container.

But, when I try to do that in Jenkins on a Managed Kubernetes, I get permission denied error.

/bitnami/jenkins/home/tools/org.jenkinsci.plugins.docker.commons.tools.DockerTool/Docker/bin/docker login -u **** -p ******** 
https://mydocker-repo/ Warning: failed to get default registry endpoint from daemon (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.29/info: dial unix /var/run/docker.sock: connect: permission denied). Using system default: https://index.docker.io/v1/ 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.29/auth: dial unix /var/run/docker.sock: connect: permission denied

Steps to reproduce the behaviour:

These are the helm values for the volume mount

extraVolumes:
  - hostPath:
      path: /var/run
    name: docker-sock
extraVolumeMounts:
   - mountPath: /var/run
     name: docker-sock

Expected behaviour:

Docker build should run properly I do not want to run the Jenkins POD as root especially, on Managed Kubernetes instance it is not allowed as well

How do I solve this error?

moonkotte
  • 3,661
  • 2
  • 10
  • 25
Ashok Krishnamoorthy
  • 853
  • 2
  • 14
  • 24
  • 1
    I'm not sure if mapping /var/run works - have your tried to map only /var/run/docker.sock – derkoe Jan 23 '22 at 15:36
  • Which kubernetes is used? Since managed is mentioned, now it usually has `containerd`. Have a look at [jenkins pod article](https://medium.com/@prasenjitsarkar_79320/jenkins-pod-docker-outside-of-docker-deployment-in-kubernetes-c76100173c28) – moonkotte Jan 24 '22 at 22:04

0 Answers0