0

I am trying to prevent Jenkins data would be lost after remove container, so that I mapped host dir for container(-v /home/jenkins/data:/var/jenkins_home). But I was not able to run container. The error I got was:

Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions? touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied

So I needed to add permission for that folder (/home/jenkins/data) or run container as jenkins user: -u jenkins.

After add this flag Jenkins is running and data after remove and recreate container is not lost. But I cannot restart Jenkins (http://jenkinshost.local/restart). I got following error: Jenkins cannot restart itself as currently configured. at the Jenkins app. This error does not occurs when I not mount host directory. I cannot install any plug-in and so on..

I am running container by:

sudo docker run -v /home/jenkins/data:/var/jenkins_home -p 80:8080 -u jenkins jenkins/jenkins

or

sudo docker run -v /home/jenkins/data:/var/jenkins_home -p 80:8080 -u jenkins jenkins/jenkins

Do you have any solution for this issue?

SOLUTION

The solution for this problem is creating volume on host instead of mapping specific folder:

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

0 Answers0