Issue
The DevOps person before me set up a Jenkins service on a Ubuntu Linux box, and it uses /var/lib/jenkins
as the JENKINS_HOME
directory. Now I want to run a jenkins/jenkins:lts
Docker container to use the same directory as its JENKINS_HOME
, so I try to do the following on the Linux host.
$ service jenkins stop
$ docker run --rm -it -p 8880:8080 --name jenkins -v /var/lib/jenkins:/var/jenkins_home jenkins/jenkins:lts
But I get
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
This is a valid way to do it correct? If so, how can I fix this error so I can run the Jenkins container using the current Jenkins service files? TIA
Solution
The "host" jenkins user:group
id's are different from the "container" jenkins user:group
id. Since I don't plan to ever start the jenkins
service on the host, I did the following on the host
$ service jenkins disable
$ chown -R 1000:1000 /var/lib/jenkins
where 1000:1000
are the user:group
id's of the jenkins user on the container. Then the docker run...
command I have in my post worked.
Answered By - Chris F
Answer Checked By - Cary Denson (JavaFixing Admin)