docker 中Jenkins更新
1.以root用户进入jenkins容器
docker exec -it -u root ContainerId bash
2.在容器中下载jenkins的最新war包
wget http://mirrors.jenkins.io/war/latest/jenkins.war
3、发现会报如下错误
--2020-04-09 06:43:09-- http://mirrors.jenkins.io/war/latest/jenkins.war Resolving mirrors.jenkins.io (mirrors.jenkins.io)... 52.202.51.185 Connecting to mirrors.jenkins.io (mirrors.jenkins.io)|52.202.51.185|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://ftp-chi.osuosl.org/pub/jenkins/war/2.230/jenkins.war [following] --2020-04-09 06:43:12-- http://ftp-chi.osuosl.org/pub/jenkins/war/2.230/jenkins.war Resolving ftp-chi.osuosl.org (ftp-chi.osuosl.org)... 64.50.236.52, 2600:3402:200:227::2 Connecting to ftp-chi.osuosl.org (ftp-chi.osuosl.org)|64.50.236.52|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 66285288 (63M) [application/x-java-archive] jenkins.war: Permission denied Cannot write to ‘jenkins.war’ (Permission denied).
这里需要进行2 步操作
1、对系统中jenkins 目录进行授权
chown -R 1000:1000 jenkins/ chown -R 777 jenkins/
2、需要在dosker 中进入安装时jenkins 挂载的目录 这里我的挂载目录是 “/var/jenkins_home”
cd /var/jenkins_home
3、在执行 下载最新war 包命令,这次就会顺利下载
wget http://mirrors.jenkins.io/war/latest/jenkins.war
--2020-04-09 06:43:32-- http://mirrors.jenkins.io/war/latest/jenkins.war Resolving mirrors.jenkins.io (mirrors.jenkins.io)... 52.202.51.185 Connecting to mirrors.jenkins.io (mirrors.jenkins.io)|52.202.51.185|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://mirror.serverion.com/jenkins/war/2.230/jenkins.war [following] --2020-04-09 06:43:39-- http://mirror.serverion.com/jenkins/war/2.230/jenkins.war Resolving mirror.serverion.com (mirror.serverion.com)... 185.126.34.191 Connecting to mirror.serverion.com (mirror.serverion.com)|185.126.34.191|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 66285288 (63M) Saving to: ‘jenkins.war’ jenkins.war 100%[====================================================>] 63.21M 9.90MB/s in 6.7s 2020-04-09 06:43:46 (9.43 MB/s) - ‘jenkins.war’ saved [66285288/66285288]
4.查看容器中jenkins war包的位置,并备份原来的war包
whereis jenkins cd /usr/share/jenkins cp jenkins.war jenkinsBAK.war
5.将/var/jenkins_home下的包cp到/usr/share/jenkins下覆盖
cp /var/jenkins_home/jenkins.war /usr/share/jenkins/
6.退出容器并重启
exit docker restart ContainerName/ContainerId
参照地址:https://www.cnblogs.com/wucaiyun1/p/11641658.html