通过如下命令启动后发现报错:Exited(1)
docker run -d -p 9000:8080 -p 50000:50000 -m 1024m -v /home/jenkins_home:/var/jenkins_home/ -v /etc/localtime:/etc/localtime —name myjenkins jenkins
以上启动通过修改了工作目录映射的改变,发现是/home/jenkins_home
目录没有写入权限导致。
logs通过docker logs myjenkins
查看发现启动jenkins的时候写入没有权限
[root@localhost home]# docker logs myjenkins
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?
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?
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?
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?
那么问题就好解决了,给映射的工作目录增加权限
[root@localhost home]# sudo chown -R 1000:1000 /home/jenkins_home/
然后再重新启动,并查看状态成功了。
[root@localhost home]# docker start 7ebb8079fb3b
7ebb8079fb3b
[root@localhost home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7ebb8079fb3b jenkinsci/jenkins "/sbin/tini -- /usr/…" 8 minutes ago Up 4 seconds 0.0.0.0:50000->50000/tcp, 0.0.0.0:9000->8080/tcp myjenkins