- docker 启动jenkins报错:
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?
- 原因分析:
官网中有提到这个问题
NOTE: Avoid using a bind mount from a folder on the host machine into /var/jenkins_home, as this might result in file permission issues (the user used inside the container might not have rights to the folder on the host machine). If you really need to bind mount jenkins_home, ensure that the directory on the host is accessible by the jenkins user inside the container (jenkins user - uid 1000) or use -u some_other_user parameter with docker run.
因为Jenkins镜像内部使用的用户是jenkins,但是我们启动容器时的账号是root,导致没有权限操作内部目录,所以加上参数 -u 0 就能解决了:
-u :覆盖容器中内置的账号
0:root账号id
- 解决办法
在docker运行容器的时候加上这么一个参数:-u 0 ,新命令如下
docker run -d -v /home/jenkins_home:/var/jenkins_home -p 8080:8080 -p 50000:50000 -u 0 --restart=on-failure jenkins/jenkins:lts-jdk11
更多内容,查看https://jhacker.cn/
评论区