docker-compose安装配置jenkins

archery

安装docker-compose

curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose


chmod 755 /usr/local/bin/docker-compose



docker-compose version

安装docker 

 yum install epel-release  yum-utils

yum-config-manager     --add-repo     https://download.docker.com/linux/centos/docker-ce.repo
 
yum install docker-ce -y

systemctl enable docker --now
 
systemctl start docker


systemctl status docker

 编写  docker-compose.yaml文件

version: '3'
services:                                      # 集合
  docker_jenkins:
    user: root                                 # 为了避免一些权限问题 在这我使用了root
    restart: always                            # 重启方式
    image: jenkins/jenkins:lts                 # 指定服务所使用的镜像 在这里我选择了 LTS (长期支持)
    container_name: jenkins                    # 容器名称
    ports:                                     # 对外暴露的端口定义
      - 8082:8080                              # 访问Jenkins服务端口
      - 50000:50000
    volumes:                                   # 卷挂载路径
      - /var/vol_dockers/jenkins_home/:/var/jenkins_home  # 这是我们一开始创建的目录挂载到容器内的jenkins_home目录
      - /var/run/docker.sock:/var/run/docker.sock
      - /usr/bin/docker:/usr/bin/docker                # 这是为了我们可以在容器内使用docker命令
      - /usr/local/bin/docker-compose:/usr/local/bin/docker-compose

启动 执行结果如下

[root@localhost docker_compose_jenkins]# docker-compose up -d
Creating network "docker_compose_jenkins_default" with the default driver
Pulling docker_jenkins (jenkins/jenkins:lts)...
lts: Pulling from jenkins/jenkins
1b13d4e1a46e: Pull complete
5303cfd924b5: Pull complete
902fe2af3265: Pull complete
866f59365203: Pull complete
da9419a1cff4: Pull complete
0f760cf88b2d: Pull complete
e1f034047864: Pull complete
b7fd15023031: Pull complete
be03ab118c25: Pull complete
13230d8adc6e: Pull complete
52b66e48bb82: Pull complete
7a718fc8b5a4: Pull complete
Digest: sha256:a786794ea0a2429e65d67a88fe497cbd97a0d73d73a39f2fd0eae3b380eb70ff
Status: Downloaded newer image for jenkins/jenkins:lts
Creating jenkins ... done

查看登录密码 

docker ps -a 
查看容器ID


docker logs a52debe35ff1      #容器id获取密码



Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

54e6428716b742d8ad6a76542f7e9bfb

This may also be found at: /var/jenkins_home/secrets/initialAdminPassword

 访问: http://jenkinsIP :8082/

配置github 凭证

申请个人github凭证

填写描述信息,  

Secret : 填写github生成的 token值 

类型: 选择  Secret text 

配置代码仓库 拉取地址 

构建

报错 无法安装插件

安装启动时 插件无法安装问题  更垃圾的是官网jenkins插件无法打开 真是老血吐一地 、

修改下载源

http://mirror.esuni.jp/jenkins/updates/update-center.json

提交修改   重启jenkins    配置文件会生效

或者修改配置文件

vim  hudson.model.UpdateCenter.xml

<?xml version='1.1' encoding='UTF-8'?>
<sites>
  <site>
    <id>default</id>
    <url>http://mirror.esuni.jp/jenkins/updates/update-center.json</url>
  </site>

修改本地校验源

修改jenkins 本地校验源   不然还是下载的updates.jenkins.io的源 

找到本地安装jenkins 路径 我的在 /home/jenkins_home/updates/default.json

先备份一下 cp default.json default.json.bak

修改 /updates.jenkins.io/download   至 mirrors.tuna.tsinghua.edu.cn 清华源

sed -i 's/https:\/\/updates.jenkins.io\/download/http:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json

   

修改google

sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json

 成功下载

报错 jenkins无法识别 系统环境命令

很奇怪,删除掉构建中的shell   重新键一下shell构建过程 居然好了 真他们神器 

解决办法: 系统配置-》 

jenkins 忘记admin密码 

 登录容器

docker exec -it  9144c407a2e6 /bin/bash

进入目录

vim /var/jenkins_home/users/admin_3120090922039879724

找到<passwordhash> 

修改密码 123456 对应的hash密码 #jbcrypt:$2a$10$LxMm9HqAI/R4z7gL57qTouW/Mrz8uSaBpCGKvKc7K6dK.g/0yk/uq 

重启容器 

docker restart  7bc05f361c8b

即可登录容器

报错:Failed to update the update site 'default'. Plugin upgrades may fail 无法启动

重启docker 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

村长在路上

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值