Could not find jenkins_home folder in Ubuntu after downloading the Docker Jenkins Image Could not find jenkins_home folder in Ubuntu after downloading the Docker Jenkins Image docker docker

Could not find jenkins_home folder in Ubuntu after downloading the Docker Jenkins Image


After starting jenkins you have 2 choices:

docker run -p 8080:8080 -d -p 50000:50000 jenkins

(The -d option is to run the container in the background)You can go inside the container and checking the initial admin passwd:check running containers

[root@localhost ~]# docker psCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                              NAMEScc73eb6d6f75        jenkins             "/bin/tini -- /usr/lo"   32 seconds ago      Up 30 seconds       0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp   ecstatic_leakey

Go inside the container

docker exec -it cc73eb6d6f75 bash

And check the content of the adminpasswd

jenkins@cc73eb6d6f75:/$ cat /var/jenkins_home/secrets/initialAdminPassword1c8be33b31904cacb5xxx

Or you create your own named docker volume:

[root@localhost ~]# docker volume create --name jenkins-volumejenkins-volume

This volume is on your host in /var/lib/docker/volumes/jenkins-volume.You can start your jenkins and connect it with the volume:

docker run -p 8080:8080 -d -p 50000:50000 -v jenkins-volume:/var/jenkins_home jenkins

All the data from /var/jenkins_volume inside your container will be mounted inside your named volume. hostpath is: /var/lib/docker/volumes/jenkins-volume/_data

So check on my host:

[root@localhost ~]# ls /var/lib/docker/volumes/jenkins-volume/_dataconfig.xml               hudson.model.UpdateCenter.xml   init.groovy.d                                jobs              nodes          secret.key                updates      warcopy_reference_file.log  hudson.plugins.git.GitTool.xml  jenkins.install.InstallUtil.lastExecVersion  logs              plugins        secret.key.not-so-secret  userContent  workspacecredentials.xml          identity.key.enc                jenkins.install.UpgradeWizard.state          nodeMonitors.xml  queue.xml.bak  secrets                   users


If you installed via the Jenkins Docker official instructions, the jenkins-data Docker volume gets automatically created in the run command. So to get the password:

sudo cat /var/lib/docker/volumes/jenkins-data/_data/secrets/initialAdminPassword


If you want to mount a host dir as jenkins_home you need to give the Jenkins user (UID 1000) ownership of that dir.

JENKINS_HOME=/home/$(whoami)/jenkins_homemkdir $JENKINS_HOMEchown -R 1000 $JENKINS_HOME

Run Jenkins container:

docker run -d --name jenkins \ -p 8080:8080 -p 50000:50000 \ -v /home/$(whoami)/jenkins_home:/var/jenkins_home \ jenkins

You can find a detailed walkthrough here on how to run Jenkins CI from a container.