前言
在使用Docker安裝Jenkins後,訪問Jenkins網址,出現Please wait while Jenkins is getting ready to work
問題。解決方法邏輯:進入Jenkins工作目錄修改hudson.model.UpdateCenter.xml即
。
將http://updates.jenkins-ci.org/update-center.json
修改爲http://mirror.xmission.com/jenkins/updates/update-center.json
操作步驟
- 進入
Jenkins的Docker容器
。
//查看運行中的Docker容器,獲取容器id
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a6c9609e332e jenkins/jenkins:lts "/sbin/tini -- /usr/…" About an hour ago Up 35 minutes 0.0.0.0:8080->8080/tcp, 50000/tcp jenkins
//進入Jenkins的Docker容器中
[root@localhost ~]# docker exec -u 0 -it a6c9609e332e /bin/bash
root@a6c9609e332e:/#
- 進入Jenkins工作目錄,查看
hudson.model.UpdateCenter.xml
文件內容。
//進入Jenkins的工作目錄
root@a6c9609e332e:/# cd /var/jenkins_home/
//查看文件
root@a6c9609e332e:/var/jenkins_home# ls
config.xml jobs secret.key.not-so-secret
copy_reference_file.log logs secrets
failed-boot-attempts.txt nodeMonitors.xml tini_pub.gpg
hudson.model.UpdateCenter.xml nodes userContent
identity.key.enc plugins users
jenkins.install.UpgradeWizard.state queue.xml.bak war
jenkins.telemetry.Correlator.xml secret.key
//查看cat hudson.model.UpdateCenter.xml文件內容
root@a6c9609e332e:/var/jenkins_home# cat hudson.model.UpdateCenter.xml
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://updates.jenkins.io/update-center.json</url>
</site>
</sites>
Docker容器內安裝vim
apt-get update
apt-get install vim
//使用vim命令,提示vim命令沒有安裝
root@235d3d236152:/var/jenkins_home# vim hudson.model.UpdateCenter.xml
bash: vim: command not found
//使用下列命令安裝vim
apt-get update
apt-get install vim
root@235d3d236152:/# apt-get update
Get:1 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
***********
root@235d3d236152:/# apt-get install vim
Reading package lists... Done
***********
- 將
[http://updates.jenkins-ci.org/update-center.json](http://updates.jenkins-ci.org/update-center.json)
修改爲[http://mirror.xmission.com/jenkins/updates/update-center.json](http://mirror.xmission.com/jenkins/updates/update-center.json)
root@235d3d236152:/var/jenkins_home# vim hudson.model.UpdateCenter.xml
root@235d3d236152:/var/jenkins_home# cat hudson.model.UpdateCenter.xml
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>http://mirror.xmission.com/jenkins/updates/update-center.json</url>
</site>
</sites>
- 最後就能成功進入Jenkins界面中。
寫在最後
在Docker中安裝vim命令的過程中,和網速有一定關係。如果覺得網速太慢,可以利用docker cp
命令將Docker容器內的hudson.model.UpdateCenter.xml
複製出來。在本地進行修改後,再使用docker cp命令拷貝到容器中。
關於docker cp命令,可以參考下面這篇博客:https://www.cnblogs.com/areyouready/p/8973495.html