1
votes

I am running jenkins inside a docker container. I have created a simple pipleline to checkout,build and run docker image, but I am getting the following error.

Below is my pipleline script:

node {
   def mvnHome = tool name: 'Maven Path', type: 'maven'
   stage('Git CheckOut') {
     git branch: '2019_DOCKER_SERVICES', credentialsId: 'git-creds', url: 'http://10.10.10.84:8111/scm/git/JEE_M_SERVICES'
   }
    stage('Maven Build') {
      // Run the maven build
      withEnv(["MVN_HOME=$mvnHome"]) {
         if (isUnix()) {
            sh '"$MVN_HOME/bin/mvn" -f Services/user-service/pom.xml clean install'
         } else {
          // bat(/"%MVN_HOME%\bin\mvn" -f Services\\user-service\\pom.xml clean install/)
         }
      }
  }
   stage('Docker Image Build') {
     sh '"Services/user-service/" docker build -t user-service'
   }


}

But I am getting the follow error in last stage, the first two stages ran successfully.

[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Docker Image Build)
[Pipeline] sh
+ Services/user-service/ docker build -t user-service
/var/jenkins_home/jobs/docker-demo/workspace@tmp/durable-a5c035cf/script.sh: 1: /var/jenkins_home/jobs/docker-demo/workspace@tmp/durable-a5c035cf/script.sh: Services/user-service/: Permission denied
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
1

1 Answers

0
votes
  1. You have to set up new Jenkins slaves using Docker
  2. It's weird to run Docker inside the Docker container
  3. To access low-level operations you have to run your Docker container privileged