4
votes

I'm transitioning my current Jenkins server to implement Docker. Following the guide on github https://github.com/jenkinsci/docker, I was able to successfully launch jenkins with the command:

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

I'm not sure how to view/access the data in my container/volume through file explorer. Is it only accessible through docker inspect? The guide in GitHub says I should avoid using a bind mount from a folder on the host machine into /var/jenkins/home. Is there another way to view and access my jenkins jobs?

1
It says that you should avoid it because of potential file permission problems, that can be solved by granting those permisionss to jenkins user on host machine. However to inspect your files on host machine, as far as I know, you can only use bind mounts to watch your files in explorer.Michał Krzywański
I agree – use "bind mounts," or better yet, "volumes." In any case, make the docker software work for you, and do things "its way." Play along with the illusion ...Mike Robinson
For Windows + docker + WSL2, this SO answer worked for me.Max Cascone

1 Answers

3
votes

As you can see in the Jenkins CI Dockerfile source code
/var/jenkins_home is declared as a VOLUME.
It means that it can be mounted on the host.
enter image description here

Your command mounts a docker volume to it but you could also mount a path on your host.
For example:

docker run -p 8080:8080 -p 50000:50000 -v ~/jenkins_home:/var/jenkins_home jenkins/jenkins:lts

On Windows hosts, you might have to create the directory first.

You can change ~/jenkins_home to whatever suites your host environment but that is a folder that you can easily navigate and inspect.

You can also still use the web interface available on the porta that you map on the host.