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 \

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

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



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/ 5'
                timeout(time: 1, unit: 'MINUTES') {
                    sh '/var/jenkins_home/scripts/ 32'

+ /home/jenkins/scripts/ 5 /var/jenkins_home/workspace/script@tmp/durable-14129c06/ 1: /var/jenkins_home/workspace/script@tmp/durable-14129c06/ /home/jenkins/scripts/ 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…

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?

you probably creating the file in the host directory. Since your Jenkins is an image in a docker, you should need to ssh to Jenkins

run this command to get a bash shell in the container
docker exec -it jenkins /bin/bash

from there you can now search the directory of jenkins_home. and start creating the scripts directory and

hope it could help