前言
今天我们来学习 docker 如何快速安装 jenkins 和禅道系统。
如果你们还没有用禅道或其他管理工具,强烈推荐下赶紧 docker 安装禅道就用用起来吧
一、doocker 安装 jenkins
1、首先要安装了 docker,可参考:https://www.cnblogs.com/gsxl/p/11674378.html
2、首先创建挂载目录:jenkins,并且给与权限(不然起不来别怪我):
# 更改目录权限:给uid为1000的权限 [root@iZbp19lugf22zbsubsf1y6Z ~]# mkdir ~/jenkins [root@iZbp19lugf22zbsubsf1y6Z ~]# chown -R 1000:1000 ~/jenkins
然后一条命令完事(只需等待下载的时间):
docker run -itd -p 3006:8080 -p 50000:50000 -v ~/jenkins:/var/jenkins_home -e JAVA_OPTS=-Duser.timezone=Asia/Shanghai --name jenkins jenkinsci/blueocean
- -p,3306是外部访问的端口,3306对应容器内部的8080端口(jenkins默认是8080端口)
- --privileged=true,开启 root 特权
- -v,将 ~/jenkins 对应挂载到容器内部工作目录 /var/jenkins_hom
- -e,jenkins 改为北京时区
- --name jenkins ,运行容器后的 name
- jenkins/jenkins:lts,镜像
3、运行结果如下:
[root@iZbp19lugf22zbsubsf1y6Z ~]# docker run -itd -p 3006:8080 -p 50000:50000 -v ~/jenkins:/var/jenkins_home -e JAVA_OPTS=-Duser.timezone=Asia/Shanghai --name jenkins jenkinsci/blueocean Unable to find image 'jenkinsci/blueocean:latest' locally latest: Pulling from jenkinsci/blueocean e7c96db7181b: Pull complete f910a506b6cb: Pull complete c2274a1a0e27: Pull complete fb11157cad2d: Pull complete 671d4a1cbe1a: Pull complete 09edd91768a5: Pull complete debb14ec40c1: Pull complete 480a5bd152f8: Pull complete cb72d6a92334: Pull complete 757db70f71a1: Pull complete 0128fdd173b0: Pull complete 9610f4e0da3f: Pull complete 210df9d82fb2: Pull complete 22f95a9fa254: Pull complete b34b4d5b5bcb: Pull complete Digest: sha256:af91aea57ac78588d281b1af34905734cdb6ebbb8dc28b8519d1dc95bad87b07 Status: Downloaded newer image for jenkinsci/blueocean:latest fa81928c4dcef3bcda052b7ae50f5ddec90445d2e849dd648e86b384b8a12bad
4、ip + 端口 在web访问(首次启动需要等待jenkins缓冲时间)
5、会提示需要输入密码,我们根据目录运行一下拿到密码 cat 目录,输入下一步即可。
[root@iZbp19lugf22zbsubsf1y6Z ~]# docker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword 7dd3a0c99c2c4bea939971e636d1eb47 [root@iZbp19lugf22zbsubsf1y6Z ~]#
6、安装推荐插件,这里强烈推荐一波更改jenkins配置文件,从此插件安装不到1分钟全完善好了
①查看容器:docker ps
[root@iZbp19lugf22zbsubsf1y6Z ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d3db015c44a6 jenkins/jenkins:lts "/sbin/tini -- /usr/…" 5 minutes ago Up 5 minutes 0.0.0.0:50000->50000/tcp, 0.0.0.0:3006->8080/tcp jenkins
②进入容器bash:docker exec -it 容器id /bin/bash
[root@iZbp19lugf22zbsubsf1y6Z ~]# docker exec -it jenkins /bin/bash
jenkins@d3db015c44a6:/$
③ cd 到 updates 目录下:执行这一句即可修改配置文件,路径是:/var/jenkins_home/updates/default.json
jenkins@dc8eac41938b:/$ cd /var/jenkins_home/updates/ jenkins@dc8eac41938b:~/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 jenkins@dc8eac41938b:~/updates$
④ exit 回来,接着重启jenkins输入:docker restart jenkins,重新打开jenkins web,选择推荐安装的插件,会发现非一般的速度给您安装好了。
7、(插件安装太慢,肯定是您没有重启jenkins)完善信息,点击下一步、下一步这样就大功告成了。
二、docker 安装禅道
1、前面也讲过 docker 安装,只需要一条命令回车就完事了:
docker run -d -p 8888:80 -p 3386:3306 -e USER="admin" -e PASSWD="123456" -e BIND_ADDRESS="false" -e SMTP_HOST="163.177.90.125 smtp.exmail.qq.com" -v /data/zbox/:/opt/zbox/ --name zentao-server idoop/zentao:latest
- 账号为:admin
- 密码为:123456
运行结果:
[root@iZbp19lugf22zbsubsf1y6Z ~]# docker run -itd -p 8888:80 -p 3316:3306 -e USER="admin" -e PASSWD="123456" -e BIND_ADDRESS="false" -e SMTP_HOST="163.177.90.125 smtp.exmail.qq.com" -v /data/zbox/:/opt/zbox/ --name zentao idoop/zentao:latest Unable to find image 'idoop/zentao:latest' locally latest: Pulling from idoop/zentao 7ddbc47eeb70: Pull complete c1bbdc448b72: Pull complete 8c3b70e39044: Pull complete 45d437916d57: Pull complete 750e6c6007ed: Pull complete c1a7f7e493d0: Pull complete ddcf1757dffa: Pull complete 988f5ca0317c: Pull complete ec88538220d9: Pull complete Digest: sha256:3355b9e6a0d5fa50552b10ed82517cc058ed7fc6e96d1a0edab333c842003ac4 Status: Downloaded newer image for idoop/zentao:latest aba48aac1f2d1c15f4456c62fdc871e65652e7c4d421b2b3bace9c1f08e3330a [root@iZbp19lugf22zbsubsf1y6Z ~]#
2、查看运行容器:docker ps
[root@iZbp19lugf22zbsubsf1y6Z ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES aba48aac1f2d idoop/zentao:latest "docker-entrypoint" 9 minutes ago Up 8 minutes (healthy) 0.0.0.0:8888->80/tcp, 0.0.0.0:3316->3306/tcp zentao
3、浏览器打开:ip + 端口
jenkins 如需汉化中文版参考这篇文章:https://www.cnblogs.com/gsxl/p/12129296.html
欢迎来QQ交流群:482713805