通过 docker 来搭建 Jenkins

mkdir /data/jenkins -p
mkdir /data/jenkins/{conf,data} -p

echo "Asia/Shanghai" > /data/jenkins/conf/timezone 

# 注意这里 jenkins 在容器的运行的 uid 为 1000;所以这里需要赋予 uid 为 1000 的权限给本地目录,否则会报错误:
chown -R 1000.1000 /data/jenkins/

docker run --name myjenkins -p 8888:8080 -p 50000:50000  -v /etc/localtime:/etc/localtime -v /data/jenkins/conf/timezone:/etc/timezone -v /data/jenkins/data:/var/jenkins_home -d jenkins

初始化的密码可在下面文件中找
/data/jenkins/data/secrets/initialAdminPassword

遇到的错误及解决办法:

1.问题:
# 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?
解决办法:
chown -R 1000.1000 /data/jenkins/

posted @ 2019-03-26 10:41  klvchen  阅读(441)  评论(0编辑  收藏  举报