Docker安装Jenkins-2.249.3-1.1的详细过程
程序员文章站
2022-06-22 16:19:59
目录一、安装docker二、拉取jenkins镜像文件三、创建挂载目录并授权四、创建并启动jenkins容器五、查看jenkins是否启动成功六、查看docker容器日志七、访问jenkins八、安装...
一、安装docker
#1.编写docker安装脚本 [root@ip-10-0-12-212 ~]# vim ins_docker.sh #!/usr/bin/bash # author:jh # time:2021-10-09 11:54:22 # name:ins_docker.sh # version: 1.0 # discription: to source /etc/init.d/functions rely_software=(yum-utils device-mapper-persistent-data lvm2) echo "-----------------#1.检测系统内核版本-----------------" kernel_version=`uname -a |awk '{print $3}'|cut -d. -f1` [ $kernel_version -ge 3 ] && action "the system install docker is ..." /usr/bin/true || action "the system can not install docker is ...";exit echo "-----------------#2.安装docker依赖软件-----------------" for i in ${rely_software[*]} do rpm -q $i &>/dev/null if [ $? -eq 0 ];then echo "$i is installed" else yum -y install $i &>/dev/null action "$i is installing" /usr/bin/true fi done echo "-----------------#3.添加docker镜像源-----------------" yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo [ $? -eq 0 ] && action "docker image add is ..." /usr/bin/true || echo "docker image add is ..." /usr/bin/false;exit echo "-----------------#4.安装docker-----------------" yum -y install docker-ce rpm -qa |grep docker-ce [ $? -eq 0 ] && action "docker-ce is installed ..." /usr/bin/true || action "docker-ce is install ..." /usr/bin/false;exit echo "-----------------#5.启动docker并设置开机自启-----------------" systemctl enable --now docker [ $? -eq 0 ] && action "docker start is ...;" /usr/bin/true || action "docker start is ..." /usr/bin/false docker_version=`docker -v |awk -f ',' '{print $1}'` echo "-----------------#6.设置docker加速器-----------------" sudo mkdir -p /etc/docker sudo cat >/etc/docker/daemon.json <<eof { "registry-mirrors": ["https://8mh75mhz.mirror.aliyuncs.com"] } eof sudo systemctl daemon-reload sudo systemctl restart docker echo "-----------------#7.查看docker是否安装完成-----------------" cat << eof +-------------------------------------------------+ | $docker_version 安 装 已 完 成 | | 请 使 用 相 关 服 务 ! | +-------------------------------------------------+ eof echo "-----------------#8.迁移docker根目录-----------------" systemctl stop docker mv /var/lib/docker/ /data/ sed -i 's#execstart=/usr/bin/dockerd#execstart=/usr/bin/dockerd --graph=/data/docker#g' /usr/lib/systemd/system/docker.service systemctl daemon-reload systemctl start docker.service echo "-----------------#9.验证docker根目录是否生效-----------------" docker info |grep "docker root dir" sleep 5 echo ""-----------------你的小可爱已完成docker全部部署-----------------" #2.给脚本添加执行权限 [root@ip-10-0-12-212 ~]# chmod +x ins_docker.sh #3.执行脚本 [root@ip-10-0-12-212 ~]# sh ins_docker.sh
二、拉取jenkins镜像文件
[root@ip-10-0-12-212 ~]# docker pull jenkins/jenkins
三、创建挂载目录并授权
[root@ip-10-0-12-212 ~]# mkdir -p /data/jenkins_mount [root@ip-10-0-12-212 ~]# chmod 777 /data/jenkins_mount
四、创建并启动jenkins容器
[root@ip-10-0-12-212 ~]# docker run -d -p 10240:8080 -p 10241:50000 -v /data/jenkins_mount:/var/jenkins_home -v /etc/localtime:/etc/localtime --name datalake_jenkins jenkins/jenkins e0a9964d61fd5eb9f1c0eae0f2f18bdbfcd03ff0d5c2cc0d0beae31c134afa75
五、查看jenkins是否启动成功
[root@ip-10-0-12-212 ~]# docker ps container id image command created status ports names e0a9964d61fd jenkins/jenkins "/sbin/tini -- /usr/…" 13 seconds ago up 12 seconds 0.0.0.0:10240->8080/tcp, :::10240->8080/tcp, 0.0.0.0:10241->50000/tcp, :::10241->50000/tcp datalake_jenkin
六、查看docker容器日志
[root@ip-10-0-12-212 ~]# docker logs datalake_jenkins running from: /usr/share/jenkins/jenkins.war webroot: envvars.masterenvvars.get("jenkins_home") 2021-10-18 02:00:12.630+0000 [id=1] info org.eclipse.jetty.util.log.log#initialized: logging initialized @1247ms to org.eclipse.jetty.util.log.javautillog 2021-10-18 02:00:12.772+0000 [id=1] info winstone.logger#loginternal: beginning extraction from war file 2021-10-18 02:00:14.184+0000 [id=1] warning o.e.j.s.handler.contexthandler#setcontextpath: empty contextpath 2021-10-18 02:00:14.319+0000 [id=1] info org.eclipse.jetty.server.server#dostart: jetty-9.4.43.v20210629; built: 2021-06-30t11:07:22.254z; git: 526006ecfa3af7f1a27ef3a288e2bef7ea9dd7e8; jvm 11.0.12+7 2021-10-18 02:00:14.887+0000 [id=1] info o.e.j.w.standarddescriptorprocessor#visitservlet: no jsp support for /, did not find org.eclipse.jetty.jsp.jettyjspservlet 2021-10-18 02:00:14.969+0000 [id=1] info o.e.j.s.s.defaultsessionidmanager#dostart: defaultsessionidmanager workername=node0 2021-10-18 02:00:14.969+0000 [id=1] info o.e.j.s.s.defaultsessionidmanager#dostart: no sessionscavenger set, using defaults 2021-10-18 02:00:14.973+0000 [id=1] info o.e.j.server.session.housekeeper#startscavenging: node0 scavenging every 660000ms 2021-10-18 02:00:15.909+0000 [id=1] info hudson.webappmain#contextinitialized: jenkins home directory: /var/jenkins_home found at: envvars.masterenvvars.get("jenkins_home") 2021-10-18 02:00:16.516+0000 [id=1] info o.e.j.s.handler.contexthandler#dostart: started w.@316a598d{jenkins v2.316,/,file:///var/jenkins_home/war/,available}{/var/jenkins_home/war} 2021-10-18 02:00:16.586+0000 [id=1] info o.e.j.server.abstractconnector#dostart: started serverconnector@505a9d7c{http/1.1, (http/1.1)}{0.0.0.0:8080}
七、访问jenkins
访问jenkins页面,http://52.82.80.128:10240
八、安装jenkins
[root@ip-10-0-12-212 ~]# cd /data/jenkins_mount/ [root@ip-10-0-12-212 jenkins_mount]# cat secrets/initialadminpassword 67925445271c4fe593ba83eede0f9c75
#2.选择安装推荐的插件
#3.填入相应的管理用户信息,点击保存并完成。
#4.配置此处jenkins的url。
#5.此处jenkins已经安装就绪,点击开始使用jenkins。
#6.此处已经进入jenkins页面,右下角显示安装的版本号,至此jenkins安装完毕。
到此这篇关于docker安装jenkins-2.249.3-1.1的文章就介绍到这了,更多相关docker安装jenkins内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
上一篇: PHP进阶:面向对象与TP5初识