Docker maven image is creating target folder owned by root and Jenkins cannot remove it from its workspace












0















I am using edited docker-maven image to compile java maven projects using Jenkins pipeline script. I mount jenkins workspace as volume for the docker. One of the first groovy scripts that run inside the pipeline cleans up the whole workspace.



However the target folder with all containings (.war file, surefire reports etc.) is created as root:root permissions. All the files are also owned by root and therefore the pipeline is failing within next run because it can not clean up workspace (Permission denied).



I investigated this issue a lot and I found two workarounds:




  • From official maven documentation - Use settings.xml and specify: filePermissions to 777 and directoryPermissions to 777. I think it is dirty fix and should not be applied...

  • Add Jenkins to sudoers and invoke a script with sudo rm -rf + on the workspace - but since we use many slave machines I would have to do this on many machines and I belive that there is a better way.


This is how my Dockerfile for maven image looks like:



FROM <our-internal-image>

RUN export http_proxy=$HTTP_PROXY &&
export https_proxy=$HTTPS_PROXY &&
zypper -n in tar which java-1_8_0-openjdk java-1_8_0-openjdk-devel &&
zypper clean &&
SUSEConnect --cleanup

RUN mkdir -p /usr/share/maven /usr/share/maven/ref &&
curl -fsSL -o /tmp/apache-maven.tar.gz https://apache.osuosl.org/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz &&
tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 &&
rm -f /tmp/apache-maven.tar.gz &&
ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

ENV JAVA_HOME /usr/lib64/jvm/java-1.8.0-openjdk
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "/root/.m2"

ENTRYPOINT ["/usr/bin/mvn"]


And this is how I invoke the compilation of our maven based module (docker-maven is name for the image created based on the Dockerfile):



def _compileMavenModule = {
stage('Build - compile maven module') {
sh "docker run " +
"--name maven-module-${BUILD_ID} " +
"--rm " +
"-v ${WORKSPACE}:/build " +
"-e http_proxy="${http_proxy}" " +
"-e https_proxy="${https_proxy}" " +
"-e HTTP_PROXY="${http_proxy}" " +
"-e HTTPS_PROXY="${https_proxy}" " +
"-e MAVEN_OPTS="-Dhttp.proxyHost=<HTTP_PROXY> -Dhttp.proxyPort=<HTTP_PROXY_PORT>-Dhttps.proxyHost=HTTP_PROXY> -Dhttps.proxyPort=<HTTP_PROXY_PORT>" " +
"docker-maven clean package -f /build/path-to-maven-repository/pom.xml"
}
}


Is there a way to run maven inside the docker image as jenkins? Or to make the files created by this docker image be jenkins:jenkins? All the other images that run ANT targets create output with jenkins:jenkins privileges. Only the maven does not... Maybe I am not aware of some setting or something. Help me please!










share|improve this question



























    0















    I am using edited docker-maven image to compile java maven projects using Jenkins pipeline script. I mount jenkins workspace as volume for the docker. One of the first groovy scripts that run inside the pipeline cleans up the whole workspace.



    However the target folder with all containings (.war file, surefire reports etc.) is created as root:root permissions. All the files are also owned by root and therefore the pipeline is failing within next run because it can not clean up workspace (Permission denied).



    I investigated this issue a lot and I found two workarounds:




    • From official maven documentation - Use settings.xml and specify: filePermissions to 777 and directoryPermissions to 777. I think it is dirty fix and should not be applied...

    • Add Jenkins to sudoers and invoke a script with sudo rm -rf + on the workspace - but since we use many slave machines I would have to do this on many machines and I belive that there is a better way.


    This is how my Dockerfile for maven image looks like:



    FROM <our-internal-image>

    RUN export http_proxy=$HTTP_PROXY &&
    export https_proxy=$HTTPS_PROXY &&
    zypper -n in tar which java-1_8_0-openjdk java-1_8_0-openjdk-devel &&
    zypper clean &&
    SUSEConnect --cleanup

    RUN mkdir -p /usr/share/maven /usr/share/maven/ref &&
    curl -fsSL -o /tmp/apache-maven.tar.gz https://apache.osuosl.org/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz &&
    tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 &&
    rm -f /tmp/apache-maven.tar.gz &&
    ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

    ENV JAVA_HOME /usr/lib64/jvm/java-1.8.0-openjdk
    ENV MAVEN_HOME /usr/share/maven
    ENV MAVEN_CONFIG "/root/.m2"

    ENTRYPOINT ["/usr/bin/mvn"]


    And this is how I invoke the compilation of our maven based module (docker-maven is name for the image created based on the Dockerfile):



    def _compileMavenModule = {
    stage('Build - compile maven module') {
    sh "docker run " +
    "--name maven-module-${BUILD_ID} " +
    "--rm " +
    "-v ${WORKSPACE}:/build " +
    "-e http_proxy="${http_proxy}" " +
    "-e https_proxy="${https_proxy}" " +
    "-e HTTP_PROXY="${http_proxy}" " +
    "-e HTTPS_PROXY="${https_proxy}" " +
    "-e MAVEN_OPTS="-Dhttp.proxyHost=<HTTP_PROXY> -Dhttp.proxyPort=<HTTP_PROXY_PORT>-Dhttps.proxyHost=HTTP_PROXY> -Dhttps.proxyPort=<HTTP_PROXY_PORT>" " +
    "docker-maven clean package -f /build/path-to-maven-repository/pom.xml"
    }
    }


    Is there a way to run maven inside the docker image as jenkins? Or to make the files created by this docker image be jenkins:jenkins? All the other images that run ANT targets create output with jenkins:jenkins privileges. Only the maven does not... Maybe I am not aware of some setting or something. Help me please!










    share|improve this question

























      0












      0








      0








      I am using edited docker-maven image to compile java maven projects using Jenkins pipeline script. I mount jenkins workspace as volume for the docker. One of the first groovy scripts that run inside the pipeline cleans up the whole workspace.



      However the target folder with all containings (.war file, surefire reports etc.) is created as root:root permissions. All the files are also owned by root and therefore the pipeline is failing within next run because it can not clean up workspace (Permission denied).



      I investigated this issue a lot and I found two workarounds:




      • From official maven documentation - Use settings.xml and specify: filePermissions to 777 and directoryPermissions to 777. I think it is dirty fix and should not be applied...

      • Add Jenkins to sudoers and invoke a script with sudo rm -rf + on the workspace - but since we use many slave machines I would have to do this on many machines and I belive that there is a better way.


      This is how my Dockerfile for maven image looks like:



      FROM <our-internal-image>

      RUN export http_proxy=$HTTP_PROXY &&
      export https_proxy=$HTTPS_PROXY &&
      zypper -n in tar which java-1_8_0-openjdk java-1_8_0-openjdk-devel &&
      zypper clean &&
      SUSEConnect --cleanup

      RUN mkdir -p /usr/share/maven /usr/share/maven/ref &&
      curl -fsSL -o /tmp/apache-maven.tar.gz https://apache.osuosl.org/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz &&
      tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 &&
      rm -f /tmp/apache-maven.tar.gz &&
      ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

      ENV JAVA_HOME /usr/lib64/jvm/java-1.8.0-openjdk
      ENV MAVEN_HOME /usr/share/maven
      ENV MAVEN_CONFIG "/root/.m2"

      ENTRYPOINT ["/usr/bin/mvn"]


      And this is how I invoke the compilation of our maven based module (docker-maven is name for the image created based on the Dockerfile):



      def _compileMavenModule = {
      stage('Build - compile maven module') {
      sh "docker run " +
      "--name maven-module-${BUILD_ID} " +
      "--rm " +
      "-v ${WORKSPACE}:/build " +
      "-e http_proxy="${http_proxy}" " +
      "-e https_proxy="${https_proxy}" " +
      "-e HTTP_PROXY="${http_proxy}" " +
      "-e HTTPS_PROXY="${https_proxy}" " +
      "-e MAVEN_OPTS="-Dhttp.proxyHost=<HTTP_PROXY> -Dhttp.proxyPort=<HTTP_PROXY_PORT>-Dhttps.proxyHost=HTTP_PROXY> -Dhttps.proxyPort=<HTTP_PROXY_PORT>" " +
      "docker-maven clean package -f /build/path-to-maven-repository/pom.xml"
      }
      }


      Is there a way to run maven inside the docker image as jenkins? Or to make the files created by this docker image be jenkins:jenkins? All the other images that run ANT targets create output with jenkins:jenkins privileges. Only the maven does not... Maybe I am not aware of some setting or something. Help me please!










      share|improve this question














      I am using edited docker-maven image to compile java maven projects using Jenkins pipeline script. I mount jenkins workspace as volume for the docker. One of the first groovy scripts that run inside the pipeline cleans up the whole workspace.



      However the target folder with all containings (.war file, surefire reports etc.) is created as root:root permissions. All the files are also owned by root and therefore the pipeline is failing within next run because it can not clean up workspace (Permission denied).



      I investigated this issue a lot and I found two workarounds:




      • From official maven documentation - Use settings.xml and specify: filePermissions to 777 and directoryPermissions to 777. I think it is dirty fix and should not be applied...

      • Add Jenkins to sudoers and invoke a script with sudo rm -rf + on the workspace - but since we use many slave machines I would have to do this on many machines and I belive that there is a better way.


      This is how my Dockerfile for maven image looks like:



      FROM <our-internal-image>

      RUN export http_proxy=$HTTP_PROXY &&
      export https_proxy=$HTTPS_PROXY &&
      zypper -n in tar which java-1_8_0-openjdk java-1_8_0-openjdk-devel &&
      zypper clean &&
      SUSEConnect --cleanup

      RUN mkdir -p /usr/share/maven /usr/share/maven/ref &&
      curl -fsSL -o /tmp/apache-maven.tar.gz https://apache.osuosl.org/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz &&
      tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 &&
      rm -f /tmp/apache-maven.tar.gz &&
      ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

      ENV JAVA_HOME /usr/lib64/jvm/java-1.8.0-openjdk
      ENV MAVEN_HOME /usr/share/maven
      ENV MAVEN_CONFIG "/root/.m2"

      ENTRYPOINT ["/usr/bin/mvn"]


      And this is how I invoke the compilation of our maven based module (docker-maven is name for the image created based on the Dockerfile):



      def _compileMavenModule = {
      stage('Build - compile maven module') {
      sh "docker run " +
      "--name maven-module-${BUILD_ID} " +
      "--rm " +
      "-v ${WORKSPACE}:/build " +
      "-e http_proxy="${http_proxy}" " +
      "-e https_proxy="${https_proxy}" " +
      "-e HTTP_PROXY="${http_proxy}" " +
      "-e HTTPS_PROXY="${https_proxy}" " +
      "-e MAVEN_OPTS="-Dhttp.proxyHost=<HTTP_PROXY> -Dhttp.proxyPort=<HTTP_PROXY_PORT>-Dhttps.proxyHost=HTTP_PROXY> -Dhttps.proxyPort=<HTTP_PROXY_PORT>" " +
      "docker-maven clean package -f /build/path-to-maven-repository/pom.xml"
      }
      }


      Is there a way to run maven inside the docker image as jenkins? Or to make the files created by this docker image be jenkins:jenkins? All the other images that run ANT targets create output with jenkins:jenkins privileges. Only the maven does not... Maybe I am not aware of some setting or something. Help me please!







      java maven docker jenkins jenkins-pipeline






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 16:40









      CrystalzordCrystalzord

      559




      559
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Pass --user option in docker run:



          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user ${env.BUILD_USER_ID}:${env.BUILD_USER_ID}" +
          "--rm " +
          "-v ${WORKSPACE}:/build " +
          "-e http_proxy="${http_proxy}" " +
          "-e https_proxy="${https_proxy}" " +
          "-e HTTP_PROXY="${http_proxy}" " +
          "-e HTTPS_PROXY="${https_proxy}" " +
          "-e MAVEN_OPTS="-Dhttp.proxyHost=<HTTP_PROXY> -Dhttp.proxyPort=<HTTP_PROXY_PORT>-Dhttps.proxyHost=HTTP_PROXY> -Dhttps.proxyPort=<HTTP_PROXY_PORT>" " +
          "docker-maven clean package -f /build/path-to-maven-repository/pom.xml"
          }


          This will pass your current user as user and group inside Docker container.



          EDIT: If those variables are empty, you can try to get the values using bash:



          user = sh(returnStdout: true, script: 'id -u').trim()
          group = sh(returnStdout: true, script: 'id -g').trim()
          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user $user:$group" +






          share|improve this answer


























          • Unfortunately this gives me an error because the values are null:null. docker: Error response from daemon: linux spec user: unable to find user null: no matching entries in passwd file.

            – Crystalzord
            Nov 19 '18 at 7:11






          • 1





            Nevermind. This gave me a hint. I specified the --user flag with jenkins:jenkins values and I have added RUN groupadd jenkins && useradd -ms /bin/bash jenkins -g jenkins to the Dockerfile and It works fine. The target is now generated as jenkins:jenkins and Jenkins can remove it from its ownspace on re-run. Thank You for the hint anyway! :)

            – Crystalzord
            Nov 19 '18 at 9:15













          • Glad to hear that!

            – madhead
            Nov 19 '18 at 10:34






          • 1





            @Crystalzord, check my edit?

            – madhead
            Nov 19 '18 at 13:58






          • 1





            Ok now I verified this on two different environments and it works correctly! Thanks again!

            – Crystalzord
            Nov 20 '18 at 10:33











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342060%2fdocker-maven-image-is-creating-target-folder-owned-by-root-and-jenkins-cannot-re%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Pass --user option in docker run:



          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user ${env.BUILD_USER_ID}:${env.BUILD_USER_ID}" +
          "--rm " +
          "-v ${WORKSPACE}:/build " +
          "-e http_proxy="${http_proxy}" " +
          "-e https_proxy="${https_proxy}" " +
          "-e HTTP_PROXY="${http_proxy}" " +
          "-e HTTPS_PROXY="${https_proxy}" " +
          "-e MAVEN_OPTS="-Dhttp.proxyHost=<HTTP_PROXY> -Dhttp.proxyPort=<HTTP_PROXY_PORT>-Dhttps.proxyHost=HTTP_PROXY> -Dhttps.proxyPort=<HTTP_PROXY_PORT>" " +
          "docker-maven clean package -f /build/path-to-maven-repository/pom.xml"
          }


          This will pass your current user as user and group inside Docker container.



          EDIT: If those variables are empty, you can try to get the values using bash:



          user = sh(returnStdout: true, script: 'id -u').trim()
          group = sh(returnStdout: true, script: 'id -g').trim()
          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user $user:$group" +






          share|improve this answer


























          • Unfortunately this gives me an error because the values are null:null. docker: Error response from daemon: linux spec user: unable to find user null: no matching entries in passwd file.

            – Crystalzord
            Nov 19 '18 at 7:11






          • 1





            Nevermind. This gave me a hint. I specified the --user flag with jenkins:jenkins values and I have added RUN groupadd jenkins && useradd -ms /bin/bash jenkins -g jenkins to the Dockerfile and It works fine. The target is now generated as jenkins:jenkins and Jenkins can remove it from its ownspace on re-run. Thank You for the hint anyway! :)

            – Crystalzord
            Nov 19 '18 at 9:15













          • Glad to hear that!

            – madhead
            Nov 19 '18 at 10:34






          • 1





            @Crystalzord, check my edit?

            – madhead
            Nov 19 '18 at 13:58






          • 1





            Ok now I verified this on two different environments and it works correctly! Thanks again!

            – Crystalzord
            Nov 20 '18 at 10:33
















          1














          Pass --user option in docker run:



          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user ${env.BUILD_USER_ID}:${env.BUILD_USER_ID}" +
          "--rm " +
          "-v ${WORKSPACE}:/build " +
          "-e http_proxy="${http_proxy}" " +
          "-e https_proxy="${https_proxy}" " +
          "-e HTTP_PROXY="${http_proxy}" " +
          "-e HTTPS_PROXY="${https_proxy}" " +
          "-e MAVEN_OPTS="-Dhttp.proxyHost=<HTTP_PROXY> -Dhttp.proxyPort=<HTTP_PROXY_PORT>-Dhttps.proxyHost=HTTP_PROXY> -Dhttps.proxyPort=<HTTP_PROXY_PORT>" " +
          "docker-maven clean package -f /build/path-to-maven-repository/pom.xml"
          }


          This will pass your current user as user and group inside Docker container.



          EDIT: If those variables are empty, you can try to get the values using bash:



          user = sh(returnStdout: true, script: 'id -u').trim()
          group = sh(returnStdout: true, script: 'id -g').trim()
          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user $user:$group" +






          share|improve this answer


























          • Unfortunately this gives me an error because the values are null:null. docker: Error response from daemon: linux spec user: unable to find user null: no matching entries in passwd file.

            – Crystalzord
            Nov 19 '18 at 7:11






          • 1





            Nevermind. This gave me a hint. I specified the --user flag with jenkins:jenkins values and I have added RUN groupadd jenkins && useradd -ms /bin/bash jenkins -g jenkins to the Dockerfile and It works fine. The target is now generated as jenkins:jenkins and Jenkins can remove it from its ownspace on re-run. Thank You for the hint anyway! :)

            – Crystalzord
            Nov 19 '18 at 9:15













          • Glad to hear that!

            – madhead
            Nov 19 '18 at 10:34






          • 1





            @Crystalzord, check my edit?

            – madhead
            Nov 19 '18 at 13:58






          • 1





            Ok now I verified this on two different environments and it works correctly! Thanks again!

            – Crystalzord
            Nov 20 '18 at 10:33














          1












          1








          1







          Pass --user option in docker run:



          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user ${env.BUILD_USER_ID}:${env.BUILD_USER_ID}" +
          "--rm " +
          "-v ${WORKSPACE}:/build " +
          "-e http_proxy="${http_proxy}" " +
          "-e https_proxy="${https_proxy}" " +
          "-e HTTP_PROXY="${http_proxy}" " +
          "-e HTTPS_PROXY="${https_proxy}" " +
          "-e MAVEN_OPTS="-Dhttp.proxyHost=<HTTP_PROXY> -Dhttp.proxyPort=<HTTP_PROXY_PORT>-Dhttps.proxyHost=HTTP_PROXY> -Dhttps.proxyPort=<HTTP_PROXY_PORT>" " +
          "docker-maven clean package -f /build/path-to-maven-repository/pom.xml"
          }


          This will pass your current user as user and group inside Docker container.



          EDIT: If those variables are empty, you can try to get the values using bash:



          user = sh(returnStdout: true, script: 'id -u').trim()
          group = sh(returnStdout: true, script: 'id -g').trim()
          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user $user:$group" +






          share|improve this answer















          Pass --user option in docker run:



          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user ${env.BUILD_USER_ID}:${env.BUILD_USER_ID}" +
          "--rm " +
          "-v ${WORKSPACE}:/build " +
          "-e http_proxy="${http_proxy}" " +
          "-e https_proxy="${https_proxy}" " +
          "-e HTTP_PROXY="${http_proxy}" " +
          "-e HTTPS_PROXY="${https_proxy}" " +
          "-e MAVEN_OPTS="-Dhttp.proxyHost=<HTTP_PROXY> -Dhttp.proxyPort=<HTTP_PROXY_PORT>-Dhttps.proxyHost=HTTP_PROXY> -Dhttps.proxyPort=<HTTP_PROXY_PORT>" " +
          "docker-maven clean package -f /build/path-to-maven-repository/pom.xml"
          }


          This will pass your current user as user and group inside Docker container.



          EDIT: If those variables are empty, you can try to get the values using bash:



          user = sh(returnStdout: true, script: 'id -u').trim()
          group = sh(returnStdout: true, script: 'id -g').trim()
          sh "docker run " +
          "--name maven-module-${BUILD_ID} " +
          "--user $user:$group" +







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 19 '18 at 13:58

























          answered Nov 16 '18 at 17:46









          madheadmadhead

          14.4k1385124




          14.4k1385124













          • Unfortunately this gives me an error because the values are null:null. docker: Error response from daemon: linux spec user: unable to find user null: no matching entries in passwd file.

            – Crystalzord
            Nov 19 '18 at 7:11






          • 1





            Nevermind. This gave me a hint. I specified the --user flag with jenkins:jenkins values and I have added RUN groupadd jenkins && useradd -ms /bin/bash jenkins -g jenkins to the Dockerfile and It works fine. The target is now generated as jenkins:jenkins and Jenkins can remove it from its ownspace on re-run. Thank You for the hint anyway! :)

            – Crystalzord
            Nov 19 '18 at 9:15













          • Glad to hear that!

            – madhead
            Nov 19 '18 at 10:34






          • 1





            @Crystalzord, check my edit?

            – madhead
            Nov 19 '18 at 13:58






          • 1





            Ok now I verified this on two different environments and it works correctly! Thanks again!

            – Crystalzord
            Nov 20 '18 at 10:33



















          • Unfortunately this gives me an error because the values are null:null. docker: Error response from daemon: linux spec user: unable to find user null: no matching entries in passwd file.

            – Crystalzord
            Nov 19 '18 at 7:11






          • 1





            Nevermind. This gave me a hint. I specified the --user flag with jenkins:jenkins values and I have added RUN groupadd jenkins && useradd -ms /bin/bash jenkins -g jenkins to the Dockerfile and It works fine. The target is now generated as jenkins:jenkins and Jenkins can remove it from its ownspace on re-run. Thank You for the hint anyway! :)

            – Crystalzord
            Nov 19 '18 at 9:15













          • Glad to hear that!

            – madhead
            Nov 19 '18 at 10:34






          • 1





            @Crystalzord, check my edit?

            – madhead
            Nov 19 '18 at 13:58






          • 1





            Ok now I verified this on two different environments and it works correctly! Thanks again!

            – Crystalzord
            Nov 20 '18 at 10:33

















          Unfortunately this gives me an error because the values are null:null. docker: Error response from daemon: linux spec user: unable to find user null: no matching entries in passwd file.

          – Crystalzord
          Nov 19 '18 at 7:11





          Unfortunately this gives me an error because the values are null:null. docker: Error response from daemon: linux spec user: unable to find user null: no matching entries in passwd file.

          – Crystalzord
          Nov 19 '18 at 7:11




          1




          1





          Nevermind. This gave me a hint. I specified the --user flag with jenkins:jenkins values and I have added RUN groupadd jenkins && useradd -ms /bin/bash jenkins -g jenkins to the Dockerfile and It works fine. The target is now generated as jenkins:jenkins and Jenkins can remove it from its ownspace on re-run. Thank You for the hint anyway! :)

          – Crystalzord
          Nov 19 '18 at 9:15







          Nevermind. This gave me a hint. I specified the --user flag with jenkins:jenkins values and I have added RUN groupadd jenkins && useradd -ms /bin/bash jenkins -g jenkins to the Dockerfile and It works fine. The target is now generated as jenkins:jenkins and Jenkins can remove it from its ownspace on re-run. Thank You for the hint anyway! :)

          – Crystalzord
          Nov 19 '18 at 9:15















          Glad to hear that!

          – madhead
          Nov 19 '18 at 10:34





          Glad to hear that!

          – madhead
          Nov 19 '18 at 10:34




          1




          1





          @Crystalzord, check my edit?

          – madhead
          Nov 19 '18 at 13:58





          @Crystalzord, check my edit?

          – madhead
          Nov 19 '18 at 13:58




          1




          1





          Ok now I verified this on two different environments and it works correctly! Thanks again!

          – Crystalzord
          Nov 20 '18 at 10:33





          Ok now I verified this on two different environments and it works correctly! Thanks again!

          – Crystalzord
          Nov 20 '18 at 10:33


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342060%2fdocker-maven-image-is-creating-target-folder-owned-by-root-and-jenkins-cannot-re%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()