Jenkins官方镜像,初始化后无法安装插件问题

建议使用Jenkins中文社区提供的jenkins镜像

jenkins的中文社区官网:https://www.jenkins.io/zh

镜像拉取地址

docker pull jenkinszh/jenkins-zh:2.267

设置挂载jenkins目录

mkdir /home/jenkins_home
chmod -R 777  /home/jenkins_home

启动容器

docker run -d -p 8080:8080 -p 50000:50000 --name jenkins-zh -v /home/jenkins_home:/var/jenkins_home jenkinszh/jenkins-zh:2.267

CentOS 安装 docker | Server 运维论坛 (learnku.com)

第二种方法:建议使用tomcat进行自定义构建镜像

  1. 选择基础镜像 ccr.ccs.tencentyun.com/wego-prod/tomcat9-jdk8:v2.0

  2. 删除里面多与的内容

    docker run -itd --name tomcat-test ccr.ccs.tencentyun.com/wego-prod/tomcat9-jdk8:v2.0
    docker exec -it tomcat-test bash
    删除多余的内容,如日记等信息
    
  3. 构建底层基础镜像

    docker commit -a "wanglinhao" -m "这是一个没有日志的tomcat镜像" 83eaf978cdb6 ccr.ccs.tencentyun.com/wego-prod/tomcat9-jdk8:wanglinhao
    docker push ccr.ccs.tencentyun.com/wego-prod/tomcat9-jdk8:wanglinhao
    
  4. 编写dockerfile

    FROM ccr.ccs.tencentyun.com/wego-prod/tomcat9-jdk8:wanglinhao
    COPY ./jenkins-2.333.war /usr/local/tomcat/webapps/ROOT.war
    
    #ENV JAVA_HOME /var/jdk1.8.0_121
    #ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin
    ENV JENKINS_HOME /var/jenkins_home
    
    # 安装git
    RUN echo > /etc/apt/sources.list \
    && echo "deb http://mirrors.163.com/debian stretch main" >> /etc/apt/sources.list \
    && echo "deb http://mirrors.163.com/debian stretch-updates main" >> /etc/apt/sources.list \
    && apt-get update \
    && apt-get install git-all -y
    
    CMD ["/usr/local/tomcat/bin/run.sh"]
    
    
    
  5. 构建镜像,下载war包

    docker build -t ccr.ccs.tencentyun.com/wego/jenkins:zh-2.333 .
    docker push ccr.ccs.tencentyun.com/wego/jenkins:zh-2.333
    
  6. 最后启动

  7. 通过war包启动的日志,初始密码位置

    cat /root/.jenkins/secrets/initialAdminPassword
    
posted @ 2022-05-20 00:47  Lin-Grocery  阅读(349)  评论(0编辑  收藏  举报