Docker 部署 Jenkins
拉取镜像
docker pull jenkins/jenkins
目录映射
mkdir -p /home/jenkins/jenkins_home
chown -R 777 /home/jenkins/jenkins_home
启动
docker run -d -u root --name jenkins -p 8080:8080 \
-e TZ=Asia/Shanghai \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
-v /home/jenkins/jenkins_home:/var/jenkins_home jenkins/jenkins
设置自启动
docker update jenkins --restart=always
安装插件提速
cd /home/jenkins/jenkins_home/
vi hudson.model.UpdateCenter.xml
修改
url
->https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
docker exec -it jenkins /bin/bash
cd /var/jenkins_home/updates
sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
exit
docker restart jenkins
解锁 Jenkins
两种方法
docker exec -it jenkins /bin/bash
cat /var/jenkins_home/secrets/initialAdminPassword
docker logs jenkins