Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-37069

Permission denied on durable task directory when using docker.image.inside step on fresh install of jenkins

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • docker-workflow-plugin

      [Maybe related to issues JENKINS-28821, JENKINS-33632 and JENKINS-36842]

      Hello,

      I am trying to stablish a new CI environment with jobs running on docker but I am running into permission issues. I tried to create a minimal reproducible scenario without slave machines.

      Looking at some of the related issues, I wonder whether I was supposed to configure permissions or group membership for the jenkins user on the container (instead of just using the image as is), but I assume that is not the case.

      Starting on a clean Centos 7 vm, I installed jenkins 2.7.1 and docker, and then added the jenkins user to the docker group (ansible playbook follows). Then I only installed "Pipeline" and "CloudBees Docker Pipeline" plugins and its dependencies. Everything is updated as of today. Then I created a single pipeline job:

      node {
         docker.image('centos:7').inside {
            sh 'pwd'
         }
      }
      

      This job fails with permission issues:

      Started by user admin
      [Pipeline] node
      Running on master in /var/lib/jenkins/workspace/container-test
      [Pipeline] {
      [Pipeline] sh
      [container-test] Running shell script
      + docker inspect -f . centos:7
      .
      [Pipeline] withDockerContainer
      $ docker run -t -d -u 992:989 -w /var/lib/jenkins/workspace/container-test -v /var/lib/jenkins/workspace/container-test:/var/lib/jenkins/workspace/container-test:rw -v /var/lib/jenkins/workspace/container-test@tmp:/var/lib/jenkins/workspace/container-test@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** centos:7 cat
      [Pipeline] {
      [container-test] Running shell script
      [Pipeline] sh
      sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/pid: Permission denied
      sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-log.txt: Permission denied
      sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-result.txt: Permission denied
      [Pipeline] }
      $ docker stop c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
      $ docker rm -f c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
      [Pipeline] // withDockerContainer
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code -2
      Finished: FAILURE
      

      Tools were installed using the following ansible recipe:

      ---
      - hosts: jenkins-minimal
      
        tasks:
        - yum: name={{ item }} state=installed
          with_items:
            - libselinux-python
            - dejavu-sans-fonts
            - fontconfig
            - java-1.8.0-openjdk-headless
            - docker
      
        - yum_repository:
            name: jenkins
            description: 'Jenkins-stable'
            baseurl: http://pkg.jenkins.io/redhat-stable
            gpgkey: http://pkg.jenkins.io/redhat-stable/jenkins.io.key
      
        - yum: name=jenkins state=installed
      
        - group: name=docker
        - user: name=jenkins groups=docker
      
        - firewalld: port=8080/tcp state=enabled permanent=true immediate=yes
      
        - service: name={{ item }} state=started enabled=yes
          with_items:
            - jenkins
            - docker
      

          [JENKINS-37069] Permission denied on durable task directory when using docker.image.inside step on fresh install of jenkins

          Vitor Dantas created issue -
          Vitor Dantas made changes -
          Description Original: [Maybe related to issues JENKINS-28821, JENKINS-33632 and JENKINS-36842]

          Hello,

          I am trying to stablish a new CI environment with jobs running on docker but I am running into permission issues. I tried to create a minimal reproducible scenario without slave machines.

          Starting on a clean Centos 7 vm, I installed jenkins 2.7.1 and docker, and then added the jenkins user to the docker group (ansible playbook follows). Then I only installed "Pipeline" and "CloudBees Docker Pipeline" plugins and its dependencies. Everything is updated as of today. Then I created a single pipeline job:

          {{
          node {
             docker.image('centos:7').inside {
                sh 'pwd'
             }
          }
          }}

          This job fails with permission issues:

          {{
          Started by user admin
          [Pipeline] node
          Running on master in /var/lib/jenkins/workspace/container-test
          [Pipeline] {
          [Pipeline] sh
          [container-test] Running shell script
          + docker inspect -f . centos:7
          .
          [Pipeline] withDockerContainer
          $ docker run -t -d -u 992:989 -w /var/lib/jenkins/workspace/container-test -v /var/lib/jenkins/workspace/container-test:/var/lib/jenkins/workspace/container-test:rw -v /var/lib/jenkins/workspace/container-test@tmp:/var/lib/jenkins/workspace/container-test@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** centos:7 cat
          [Pipeline] {
          [container-test] Running shell script
          [Pipeline] sh
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/pid: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-log.txt: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-result.txt: Permission denied
          [Pipeline] }
          $ docker stop c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          $ docker rm -f c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          [Pipeline] // withDockerContainer
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -2
          Finished: FAILURE
          }}

          Tools were installed using the following ansible recipe:
          {{
          ---
          - hosts: jenkins-minimal

            tasks:
            - yum: name={{ item }} state=installed
              with_items:
                - libselinux-python
                - dejavu-sans-fonts
                - fontconfig
                - java-1.8.0-openjdk-headless
                - docker

            - yum_repository:
                name: jenkins
                description: 'Jenkins-stable'
                baseurl: http://pkg.jenkins.io/redhat-stable
                gpgkey: http://pkg.jenkins.io/redhat-stable/jenkins.io.key

            - yum: name=jenkins state=installed

            - group: name=docker
            - user: name=jenkins groups=docker

            - firewalld: port=8080/tcp state=enabled permanent=true immediate=yes

            - service: name={{ item }} state=started enabled=yes
              with_items:
                - jenkins
                - docker
          }}
          New: [Maybe related to issues JENKINS-28821, JENKINS-33632 and JENKINS-36842]

          Hello,

          I am trying to stablish a new CI environment with jobs running on docker but I am running into permission issues. I tried to create a minimal reproducible scenario without slave machines.

          Starting on a clean Centos 7 vm, I installed jenkins 2.7.1 and docker, and then added the jenkins user to the docker group (ansible playbook follows). Then I only installed "Pipeline" and "CloudBees Docker Pipeline" plugins and its dependencies. Everything is updated as of today. Then I created a single pipeline job:

          {{node {
             docker.image('centos:7').inside {
                sh 'pwd'
             }
          }
          }}

          This job fails with permission issues:

          {{
          Started by user admin
          [Pipeline] node
          Running on master in /var/lib/jenkins/workspace/container-test
          [Pipeline] {
          [Pipeline] sh
          [container-test] Running shell script
          + docker inspect -f . centos:7
          .
          [Pipeline] withDockerContainer
          $ docker run -t -d -u 992:989 -w /var/lib/jenkins/workspace/container-test -v /var/lib/jenkins/workspace/container-test:/var/lib/jenkins/workspace/container-test:rw -v /var/lib/jenkins/workspace/container-test@tmp:/var/lib/jenkins/workspace/container-test@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** centos:7 cat
          [Pipeline] {
          [container-test] Running shell script
          [Pipeline] sh
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/pid: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-log.txt: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-result.txt: Permission denied
          [Pipeline] }
          $ docker stop c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          $ docker rm -f c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          [Pipeline] // withDockerContainer
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -2
          Finished: FAILURE
          }}

          Tools were installed using the following ansible recipe:
          {{
          ---
          - hosts: jenkins-minimal

            tasks:
            - yum: name={{ item }} state=installed
              with_items:
                - libselinux-python
                - dejavu-sans-fonts
                - fontconfig
                - java-1.8.0-openjdk-headless
                - docker

            - yum_repository:
                name: jenkins
                description: 'Jenkins-stable'
                baseurl: http://pkg.jenkins.io/redhat-stable
                gpgkey: http://pkg.jenkins.io/redhat-stable/jenkins.io.key

            - yum: name=jenkins state=installed

            - group: name=docker
            - user: name=jenkins groups=docker

            - firewalld: port=8080/tcp state=enabled permanent=true immediate=yes

            - service: name={{ item }} state=started enabled=yes
              with_items:
                - jenkins
                - docker
          }}
          Vitor Dantas made changes -
          Description Original: [Maybe related to issues JENKINS-28821, JENKINS-33632 and JENKINS-36842]

          Hello,

          I am trying to stablish a new CI environment with jobs running on docker but I am running into permission issues. I tried to create a minimal reproducible scenario without slave machines.

          Starting on a clean Centos 7 vm, I installed jenkins 2.7.1 and docker, and then added the jenkins user to the docker group (ansible playbook follows). Then I only installed "Pipeline" and "CloudBees Docker Pipeline" plugins and its dependencies. Everything is updated as of today. Then I created a single pipeline job:

          {{node {
             docker.image('centos:7').inside {
                sh 'pwd'
             }
          }
          }}

          This job fails with permission issues:

          {{
          Started by user admin
          [Pipeline] node
          Running on master in /var/lib/jenkins/workspace/container-test
          [Pipeline] {
          [Pipeline] sh
          [container-test] Running shell script
          + docker inspect -f . centos:7
          .
          [Pipeline] withDockerContainer
          $ docker run -t -d -u 992:989 -w /var/lib/jenkins/workspace/container-test -v /var/lib/jenkins/workspace/container-test:/var/lib/jenkins/workspace/container-test:rw -v /var/lib/jenkins/workspace/container-test@tmp:/var/lib/jenkins/workspace/container-test@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** centos:7 cat
          [Pipeline] {
          [container-test] Running shell script
          [Pipeline] sh
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/pid: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-log.txt: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-result.txt: Permission denied
          [Pipeline] }
          $ docker stop c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          $ docker rm -f c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          [Pipeline] // withDockerContainer
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -2
          Finished: FAILURE
          }}

          Tools were installed using the following ansible recipe:
          {{
          ---
          - hosts: jenkins-minimal

            tasks:
            - yum: name={{ item }} state=installed
              with_items:
                - libselinux-python
                - dejavu-sans-fonts
                - fontconfig
                - java-1.8.0-openjdk-headless
                - docker

            - yum_repository:
                name: jenkins
                description: 'Jenkins-stable'
                baseurl: http://pkg.jenkins.io/redhat-stable
                gpgkey: http://pkg.jenkins.io/redhat-stable/jenkins.io.key

            - yum: name=jenkins state=installed

            - group: name=docker
            - user: name=jenkins groups=docker

            - firewalld: port=8080/tcp state=enabled permanent=true immediate=yes

            - service: name={{ item }} state=started enabled=yes
              with_items:
                - jenkins
                - docker
          }}
          New: [Maybe related to issues JENKINS-28821, JENKINS-33632 and JENKINS-36842]

          Hello,

          I am trying to stablish a new CI environment with jobs running on docker but I am running into permission issues. I tried to create a minimal reproducible scenario without slave machines.

          Starting on a clean Centos 7 vm, I installed jenkins 2.7.1 and docker, and then added the jenkins user to the docker group (ansible playbook follows). Then I only installed "Pipeline" and "CloudBees Docker Pipeline" plugins and its dependencies. Everything is updated as of today. Then I created a single pipeline job:

          {noformat}
          node {
             docker.image('centos:7').inside {
                sh 'pwd'
             }
          }
          {noformat}

          This job fails with permission issues:

          {{
          Started by user admin
          [Pipeline] node
          Running on master in /var/lib/jenkins/workspace/container-test
          [Pipeline] {
          [Pipeline] sh
          [container-test] Running shell script
          + docker inspect -f . centos:7
          .
          [Pipeline] withDockerContainer
          $ docker run -t -d -u 992:989 -w /var/lib/jenkins/workspace/container-test -v /var/lib/jenkins/workspace/container-test:/var/lib/jenkins/workspace/container-test:rw -v /var/lib/jenkins/workspace/container-test@tmp:/var/lib/jenkins/workspace/container-test@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** centos:7 cat
          [Pipeline] {
          [container-test] Running shell script
          [Pipeline] sh
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/pid: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-log.txt: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-result.txt: Permission denied
          [Pipeline] }
          $ docker stop c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          $ docker rm -f c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          [Pipeline] // withDockerContainer
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -2
          Finished: FAILURE
          }}

          Tools were installed using the following ansible recipe:
          {{
          ---
          - hosts: jenkins-minimal

            tasks:
            - yum: name={{ item }} state=installed
              with_items:
                - libselinux-python
                - dejavu-sans-fonts
                - fontconfig
                - java-1.8.0-openjdk-headless
                - docker

            - yum_repository:
                name: jenkins
                description: 'Jenkins-stable'
                baseurl: http://pkg.jenkins.io/redhat-stable
                gpgkey: http://pkg.jenkins.io/redhat-stable/jenkins.io.key

            - yum: name=jenkins state=installed

            - group: name=docker
            - user: name=jenkins groups=docker

            - firewalld: port=8080/tcp state=enabled permanent=true immediate=yes

            - service: name={{ item }} state=started enabled=yes
              with_items:
                - jenkins
                - docker
          }}
          Vitor Dantas made changes -
          Description Original: [Maybe related to issues JENKINS-28821, JENKINS-33632 and JENKINS-36842]

          Hello,

          I am trying to stablish a new CI environment with jobs running on docker but I am running into permission issues. I tried to create a minimal reproducible scenario without slave machines.

          Starting on a clean Centos 7 vm, I installed jenkins 2.7.1 and docker, and then added the jenkins user to the docker group (ansible playbook follows). Then I only installed "Pipeline" and "CloudBees Docker Pipeline" plugins and its dependencies. Everything is updated as of today. Then I created a single pipeline job:

          {noformat}
          node {
             docker.image('centos:7').inside {
                sh 'pwd'
             }
          }
          {noformat}

          This job fails with permission issues:

          {{
          Started by user admin
          [Pipeline] node
          Running on master in /var/lib/jenkins/workspace/container-test
          [Pipeline] {
          [Pipeline] sh
          [container-test] Running shell script
          + docker inspect -f . centos:7
          .
          [Pipeline] withDockerContainer
          $ docker run -t -d -u 992:989 -w /var/lib/jenkins/workspace/container-test -v /var/lib/jenkins/workspace/container-test:/var/lib/jenkins/workspace/container-test:rw -v /var/lib/jenkins/workspace/container-test@tmp:/var/lib/jenkins/workspace/container-test@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** centos:7 cat
          [Pipeline] {
          [container-test] Running shell script
          [Pipeline] sh
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/pid: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-log.txt: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-result.txt: Permission denied
          [Pipeline] }
          $ docker stop c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          $ docker rm -f c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          [Pipeline] // withDockerContainer
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -2
          Finished: FAILURE
          }}

          Tools were installed using the following ansible recipe:
          {{
          ---
          - hosts: jenkins-minimal

            tasks:
            - yum: name={{ item }} state=installed
              with_items:
                - libselinux-python
                - dejavu-sans-fonts
                - fontconfig
                - java-1.8.0-openjdk-headless
                - docker

            - yum_repository:
                name: jenkins
                description: 'Jenkins-stable'
                baseurl: http://pkg.jenkins.io/redhat-stable
                gpgkey: http://pkg.jenkins.io/redhat-stable/jenkins.io.key

            - yum: name=jenkins state=installed

            - group: name=docker
            - user: name=jenkins groups=docker

            - firewalld: port=8080/tcp state=enabled permanent=true immediate=yes

            - service: name={{ item }} state=started enabled=yes
              with_items:
                - jenkins
                - docker
          }}
          New: [Maybe related to issues JENKINS-28821, JENKINS-33632 and JENKINS-36842]

          Hello,

          I am trying to stablish a new CI environment with jobs running on docker but I am running into permission issues. I tried to create a minimal reproducible scenario without slave machines.

          Starting on a clean Centos 7 vm, I installed jenkins 2.7.1 and docker, and then added the jenkins user to the docker group (ansible playbook follows). Then I only installed "Pipeline" and "CloudBees Docker Pipeline" plugins and its dependencies. Everything is updated as of today. Then I created a single pipeline job:

          {noformat}
          node {
             docker.image('centos:7').inside {
                sh 'pwd'
             }
          }
          {noformat}

          This job fails with permission issues:

          {noformat}
          Started by user admin
          [Pipeline] node
          Running on master in /var/lib/jenkins/workspace/container-test
          [Pipeline] {
          [Pipeline] sh
          [container-test] Running shell script
          + docker inspect -f . centos:7
          .
          [Pipeline] withDockerContainer
          $ docker run -t -d -u 992:989 -w /var/lib/jenkins/workspace/container-test -v /var/lib/jenkins/workspace/container-test:/var/lib/jenkins/workspace/container-test:rw -v /var/lib/jenkins/workspace/container-test@tmp:/var/lib/jenkins/workspace/container-test@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** centos:7 cat
          [Pipeline] {
          [container-test] Running shell script
          [Pipeline] sh
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/pid: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-log.txt: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-result.txt: Permission denied
          [Pipeline] }
          $ docker stop c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          $ docker rm -f c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          [Pipeline] // withDockerContainer
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -2
          Finished: FAILURE
          {noformat}

          Tools were installed using the following ansible recipe:
          {noformat}
          ---
          - hosts: jenkins-minimal

            tasks:
            - yum: name={{ item }} state=installed
              with_items:
                - libselinux-python
                - dejavu-sans-fonts
                - fontconfig
                - java-1.8.0-openjdk-headless
                - docker

            - yum_repository:
                name: jenkins
                description: 'Jenkins-stable'
                baseurl: http://pkg.jenkins.io/redhat-stable
                gpgkey: http://pkg.jenkins.io/redhat-stable/jenkins.io.key

            - yum: name=jenkins state=installed

            - group: name=docker
            - user: name=jenkins groups=docker

            - firewalld: port=8080/tcp state=enabled permanent=true immediate=yes

            - service: name={{ item }} state=started enabled=yes
              with_items:
                - jenkins
                - docker
          {noformat}
          Vitor Dantas made changes -
          Description Original: [Maybe related to issues JENKINS-28821, JENKINS-33632 and JENKINS-36842]

          Hello,

          I am trying to stablish a new CI environment with jobs running on docker but I am running into permission issues. I tried to create a minimal reproducible scenario without slave machines.

          Starting on a clean Centos 7 vm, I installed jenkins 2.7.1 and docker, and then added the jenkins user to the docker group (ansible playbook follows). Then I only installed "Pipeline" and "CloudBees Docker Pipeline" plugins and its dependencies. Everything is updated as of today. Then I created a single pipeline job:

          {noformat}
          node {
             docker.image('centos:7').inside {
                sh 'pwd'
             }
          }
          {noformat}

          This job fails with permission issues:

          {noformat}
          Started by user admin
          [Pipeline] node
          Running on master in /var/lib/jenkins/workspace/container-test
          [Pipeline] {
          [Pipeline] sh
          [container-test] Running shell script
          + docker inspect -f . centos:7
          .
          [Pipeline] withDockerContainer
          $ docker run -t -d -u 992:989 -w /var/lib/jenkins/workspace/container-test -v /var/lib/jenkins/workspace/container-test:/var/lib/jenkins/workspace/container-test:rw -v /var/lib/jenkins/workspace/container-test@tmp:/var/lib/jenkins/workspace/container-test@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** centos:7 cat
          [Pipeline] {
          [container-test] Running shell script
          [Pipeline] sh
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/pid: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-log.txt: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-result.txt: Permission denied
          [Pipeline] }
          $ docker stop c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          $ docker rm -f c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          [Pipeline] // withDockerContainer
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -2
          Finished: FAILURE
          {noformat}

          Tools were installed using the following ansible recipe:
          {noformat}
          ---
          - hosts: jenkins-minimal

            tasks:
            - yum: name={{ item }} state=installed
              with_items:
                - libselinux-python
                - dejavu-sans-fonts
                - fontconfig
                - java-1.8.0-openjdk-headless
                - docker

            - yum_repository:
                name: jenkins
                description: 'Jenkins-stable'
                baseurl: http://pkg.jenkins.io/redhat-stable
                gpgkey: http://pkg.jenkins.io/redhat-stable/jenkins.io.key

            - yum: name=jenkins state=installed

            - group: name=docker
            - user: name=jenkins groups=docker

            - firewalld: port=8080/tcp state=enabled permanent=true immediate=yes

            - service: name={{ item }} state=started enabled=yes
              with_items:
                - jenkins
                - docker
          {noformat}
          New: [Maybe related to issues JENKINS-28821, JENKINS-33632 and JENKINS-36842]

          Hello,

          I am trying to stablish a new CI environment with jobs running on docker but I am running into permission issues. I tried to create a minimal reproducible scenario without slave machines.

          Looking at some of the related issues, I wonder whether I was supposed to configure permissions or group membership for the jenkins user on the container (instead of just using the image as is), but I assume that is not the case.

          Starting on a clean Centos 7 vm, I installed jenkins 2.7.1 and docker, and then added the jenkins user to the docker group (ansible playbook follows). Then I only installed "Pipeline" and "CloudBees Docker Pipeline" plugins and its dependencies. Everything is updated as of today. Then I created a single pipeline job:

          {noformat}
          node {
             docker.image('centos:7').inside {
                sh 'pwd'
             }
          }
          {noformat}

          This job fails with permission issues:

          {noformat}
          Started by user admin
          [Pipeline] node
          Running on master in /var/lib/jenkins/workspace/container-test
          [Pipeline] {
          [Pipeline] sh
          [container-test] Running shell script
          + docker inspect -f . centos:7
          .
          [Pipeline] withDockerContainer
          $ docker run -t -d -u 992:989 -w /var/lib/jenkins/workspace/container-test -v /var/lib/jenkins/workspace/container-test:/var/lib/jenkins/workspace/container-test:rw -v /var/lib/jenkins/workspace/container-test@tmp:/var/lib/jenkins/workspace/container-test@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** centos:7 cat
          [Pipeline] {
          [container-test] Running shell script
          [Pipeline] sh
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/pid: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-log.txt: Permission denied
          sh: /var/lib/jenkins/workspace/container-test@tmp/durable-890dccc6/jenkins-result.txt: Permission denied
          [Pipeline] }
          $ docker stop c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          $ docker rm -f c71c65555ff53a1bd87db33a9d240c6eb4ae14d9c61a0a0a348c7f72f82b7a50
          [Pipeline] // withDockerContainer
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -2
          Finished: FAILURE
          {noformat}

          Tools were installed using the following ansible recipe:
          {noformat}
          ---
          - hosts: jenkins-minimal

            tasks:
            - yum: name={{ item }} state=installed
              with_items:
                - libselinux-python
                - dejavu-sans-fonts
                - fontconfig
                - java-1.8.0-openjdk-headless
                - docker

            - yum_repository:
                name: jenkins
                description: 'Jenkins-stable'
                baseurl: http://pkg.jenkins.io/redhat-stable
                gpgkey: http://pkg.jenkins.io/redhat-stable/jenkins.io.key

            - yum: name=jenkins state=installed

            - group: name=docker
            - user: name=jenkins groups=docker

            - firewalld: port=8080/tcp state=enabled permanent=true immediate=yes

            - service: name={{ item }} state=started enabled=yes
              with_items:
                - jenkins
                - docker
          {noformat}

          Jesse Glick added a comment -

          I wonder whether I was supposed to configure permissions or group membership for the jenkins user on the container (instead of just using the image as is)

          No; Jenkins tries to run the container using the user (and group) ID from the slave agent on the host, specifically so that it will have write permissions on the workspace. Not sure why that is not working in this case.

          Jesse Glick added a comment - I wonder whether I was supposed to configure permissions or group membership for the jenkins user on the container (instead of just using the image as is) No; Jenkins tries to run the container using the user (and group) ID from the slave agent on the host, specifically so that it will have write permissions on the workspace. Not sure why that is not working in this case.

          Vitor Dantas added a comment -

          Inside the container, the jenkins user and jenkins group don't exist (992:989 on this setup). I checked this by looking at the /etc/passwd and /etc/groups files using docker exec <container_id> cat <path>. Is it supposed to be that way?

          Vitor Dantas added a comment - Inside the container, the jenkins user and jenkins group don't exist (992:989 on this setup). I checked this by looking at the /etc/passwd and /etc/groups files using docker exec <container_id> cat <path>. Is it supposed to be that way?

          Vitor Dantas added a comment -

          Well, the problem is solved for me when using Docker 1.12.0 (installed from the Docker project repository). When I revert to Docker 1.10.3, which is the version available today on default Centos 7 "extras" repository, the errors are back.

          Current Pipeline implementation is somehow incompatible with Docker 1.10, which for me was unexpected.

          Vitor Dantas added a comment - Well, the problem is solved for me when using Docker 1.12.0 (installed from the Docker project repository). When I revert to Docker 1.10.3, which is the version available today on default Centos 7 "extras" repository, the errors are back. Current Pipeline implementation is somehow incompatible with Docker 1.10, which for me was unexpected.
          Jesse Glick made changes -
          Component/s Original: durable-task-plugin [ 18622 ]

          Vitor Dantas added a comment -

          By the way, Docker 1.10 is still being shipped in recent images from Project Atomic (see http://www.projectatomic.io/blog/2016/07/new-centos-atomic-host-releases-available-for-download/). I wonder why other people are not complaining about this incompatibility of the inside step with Docker 1.10, since I assume lots of people are spinning slaves from a default image of Centos 7 with docker installed from default repos or from a default image of Centos Atomic Host.

          For me, as I reported in a reproducible way (the ansible recipe and pipeline script) the inside step would not work with such common slaves. I don't know if I'm missing something.

          Vitor Dantas added a comment - By the way, Docker 1.10 is still being shipped in recent images from Project Atomic (see http://www.projectatomic.io/blog/2016/07/new-centos-atomic-host-releases-available-for-download/ ). I wonder why other people are not complaining about this incompatibility of the inside step with Docker 1.10, since I assume lots of people are spinning slaves from a default image of Centos 7 with docker installed from default repos or from a default image of Centos Atomic Host. For me, as I reported in a reproducible way (the ansible recipe and pipeline script) the inside step would not work with such common slaves. I don't know if I'm missing something.

            Unassigned Unassigned
            seuvitor Vitor Dantas
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: