[Jenkins][Docker]java.io.IOException: Permission denied

问题描述

打算将Jenkins部署到云服务器上,实现步骤如下:

  1. 将本地Docker Volume打包后发送到云服务器并解压
  2. 在云服务器下载Jenkins镜像并启动

打开首页,发现如下错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2024)
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:142)
Caused: java.io.IOException: Failed to create a temporary file in /var/jenkins_home
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:144)
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:109)
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:84)
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:74)
at hudson.XmlFile.write(XmlFile.java:189)
at jenkins.model.Jenkins.save(Jenkins.java:3382)
at jenkins.model.Jenkins.<init>(Jenkins.java:985)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:262)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain$3.run(WebAppMain.java:279)

问题解决

有可能是权限问题,对比本地Jenkins镜像后,发现云服务器上的/var/jenkins_home目录所属的用户和组均为root,将其重设为jenkins后,问题解决

1
$ chown -R jenkins:jenkins /var/jenkins_home

相关阅读