jekins官网地址:Jenkins Plugins (https://plugins.jenkins.io/)
jekins 的docker 官方地址:https://hub.docker.com/r/jenkins/jenkins
jekins 的docker 允许命令文档地址: docker/README.md at master · jenkinsci/docker · GitHub
(https://github.com/jenkinsci/docker/blob/master/README.md)
docker 拉取jekins镜像:docker pull jenkins/jenkins (直接拉取最新的,我是最新的jdk17)
wangqinmin@wangqinmindembp ~ % docker pull jenkins/jenkins
Using default tag: latest
latest: Pulling from jenkins/jenkins
fea1432adf09: Pull complete
db129cca7868: Pull complete
99af34bcd043: Pull complete
d8ad0a3a0d7d: Pull complete
4247e112c6e3: Pull complete
999d643d2a0b: Pull complete
276b37e5676e: Pull complete
98d066d323e3: Pull complete
633994ff33f4: Pull complete
6d759019a0a2: Pull complete
983cb4661b02: Pull complete
45f887daec50: Pull complete
Digest: sha256:69121259e1517cc727afcad0482475b626cb90fda8611d816fed2fac0e914cb4
Status: Downloaded newer image for jenkins/jenkins:latest
docker.io/jenkins/jenkins:latest
docker查看镜像:docker images
wangqinmin@wangqinmindembp ~ % docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jenkins/jenkins latest fea411dfc883 2 days ago 469MB
先创建jenkins的文件挂载目录,我创建的文件地址是:/Users/wangqinmin/docker/jenkins
wangqinmin@wangqinmindembp docker % pwd
/Users/wangqinmin/docker
wangqinmin@wangqinmindembp docker % mkdir jenkins
wangqinmin@wangqinmindembp docker % ls
jenkins mysql
wangqinmin@wangqinmindembp docker % cd jenkins
wangqinmin@wangqinmindembp jenkins % pwd
/Users/wangqinmin/docker/jenkins
docker运行命令,并启动:
docker run --name jenkins17 -d -v jenkins_home:/Users/wangqinmin/docker/jenkins -p 8080:8080 -p 50000:50000 --restart=on-failure jenkins/jenkins
解释:
docker run
--name jenkins17 自定义启动名称
-d 后台运行容器
-v jenkins_home:/Users/wangqinmin/docker/jenkins 挂载文件到指定的目录
-p 8080:8080 指定访问端口号,前面的8080是访问的端口号可以改,后面的8080是内部的端口号不能改
-p 50000:50000
--restart=on-failure
jenkins/jenkins 这个是 docker images 命令获取到的 REPOSITORY 列下面的数据
访问地址: localhost:8080
查看docker运行 容器列表,看 jenkins 命令:docker ps -a
wangqinmin@wangqinmindembp jenkins % docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
90fca6a924c5 jenkins/jenkins "/usr/bin/tini -- /u…" 4 seconds ago Up 3 seconds 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:50000->50000/tcp, :::50000->50000/tcp jenkins17
找密码:
查看jenkins 服务器后台:
docker exec -it jenkins17 /bin/bash
找到密码文件:
wangqinmin@wangqinmindembp jenkins % docker exec -it jenkins17 /bin/bash
jenkins@90fca6a924c5:/$ ls
Users bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
jenkins@90fca6a924c5:/$ cd /var/jenkins_home/secrets
jenkins@90fca6a924c5:~/secrets$ ls
initialAdminPassword jenkins.model.Jenkins.crumbSalt master.key
查看密码:
jenkins@90fca6a924c5:~/secrets$ cat initialAdminPassword
3a359747885f46c3ab68742a7334df02
jenkins@90fca6a924c5:~/secrets$
复制密码:3a359747885f46c3ab68742a7334df02
然后先安装一些推荐插件,后面再根据需要安装插件即可。
部分安装失败,先不管,后面再说,先点继续,去改密码
新建一个用户,点击 保存并完成,就好了
完成: