Docker Community Forums

Share and learn in the Docker community.

Running a script in jenkins under docker, error: cannot find /var/jenkins_home

  • Issue type configuration of running docker with jenkins
  • OS Version/build Windows 10 Home WSL2
  • App version Docker Desktop for Windows 20.10 LTS, jenkins/jenkins:lts, Jenkins 2.263.3
  • Steps to reproduce

I am learning Jenkins and was trying to run it in a docker image.

In an ubuntu terminal (Windows 10 Home WSL2) I ran the provided code from the tutorial (Jenkins Essential Training):

I ran it under root

useradd jenkins -m 
docker run \
 -u jenkins \
 --rm \
 -d \
 -p 8080:8080 \
 -p 50000:50000 \
 -v /var/run/docker.sock:/var/run/docker.sock \
 -v /home/jenkins:/var/jenkins_home \
 jenkins/jenkins:lts 

This part of the command I ran before appears to have failed

-v /home/jenkins:/var/jenkins_home </b>

from

jenkins/jenkins:lts

because when I try to run the script in the tutorial, it fails.

pipeline {
    agent any
    stages {
        stage('Deploy') {
            steps {
                timeout(time: 1, unit: 'MINUTES') {
                    sh '/var/jenkins_home/scripts/fibonacci.sh 5'
                }
                timeout(time: 1, unit: 'MINUTES') {
                    sh '/var/jenkins_home/scripts/fibonacci.sh 32'
                }
            }
        }
    }
}

+ /home/jenkins/scripts/fibonacci.sh 5 /var/jenkins_home/workspace/script@tmp/durable-14129c06/script.sh: 1: /var/jenkins_home/workspace/script@tmp/durable-14129c06/script.sh: /home/jenkins/scripts/fibonacci.sh: not found


There is no /var/jenkins_home folder

jenkins:~$ cd /var

jenkins:/var$ ls

backups cache crash lib local lock log mail opt run snap spool tmp

Any suggestions appreciated…

thank you for your information
nice post
Merchant crypto

I opened the Docker CLI and saw the /var/jenkins_home files were there in the CLI view, but not in the host ubuntu terminal view.
Then I went back to the Jenkins UI and ran it again, and this time it worked. :smiley:
Very strange, but anyway.
Perhaps it is a bug with the WSL2 and Jenkins file sharing?