Pod running in EKS worker node not able to access docker daemon

5/17/2019

I have a jenkins-slave image in which I have added jenkins to docker group

RUN usermod -aG docker jenkins

And then I use this image in a job as follows

podTemplate(label: 'builder-pod-startclust', cloud: 'kubernetes', containers: [
    containerTemplate(
            name: 'jnlp',
            image: "${artifact_repo}/jenkins-slave:ekslave",
            ttyEnabled: true,
            privileged: true,
            alwaysPullImage: true,
            workingDir: '/var/jenkins_home',
            resourceRequestCpu: '1000m',
            resourceRequestMemory: '1Gi',
            resourceLimitMemory: '1.1Gi',
    )
], volumes: [hostPathVolume(mountPath: '/var/run', hostPath: '/var/run')],
   annotations: [
                podAnnotation(key: 'iam.amazonaws.com/role', value: 'arn:aws:iam::XXXXXXXX:role/kube2iam-role')
        ]) { //podtemplate

However, running docker commands ,eg , docker version , in the jenkins-slave pod runs into permission issues

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.39/version: dial unix /var/run/docker.sock: connect: permission denied

The jenkins master yaml is as follows

containers:
      - name: jenkins-container
        image: $artifact_repo/jenkins:latest
...

     volumeMounts:
              - mountPath: /var/run
                name: docker-sock
-- smk
amazon-eks
kubernetes

0 Answers