Docker搭建Jenkins

Jenkins安装

#下载镜像
docker pull docker.io/jenkins  
#创建卷
docker volume create --name jenkins-home
#启动容器
docker run -p 6002:8080 -d -p 50000:50000 --name jenkins -v jenkins-home:/var/jenkins_home jenkins
#获取首次登录密码
docker exec -it  jenkins bash
cat /var/jenkins_home/secrets/initialAdminPassword

访问地址:http://localhost:6002

Jenkins升级

进入 Jenkins 容器在宿主机的挂载目录/home/jenkins中

#查看挂载的目录路径
docker volume inspect jenkins-home
cd cd /var/lib/docker/volumes/jenkins-home/_data
#在 CentOS7 中下载Jenkins的最新war包
wget http://mirrors.jenkins.io/war/latest/jenkins.war
#进入容器
docker exec -it -u root +ContainerId bash
#查看容器中jenkins war包的位置,并备份原来的war包
whereis jenkins
cd /usr/share/jenkins
cp jenkins.war jenkinsBAK.war
将/var/jenkins_home下的包cp到/usr/share/jenkins下覆盖
cp /var/jenkins_home/jenkins.war /usr/share/jenkins/
退出容器并重启
exit
docker restart +ContainerName 

插件安装

Jenkins插件下载:
默认下载地址:
http://updates.jenkins-ci.org/update-center.json
网络不行 更换为:
http://mirror.xmission.com/jenkins/updates/update-center.json

你可能感兴趣的:(Docker搭建Jenkins)