zoukankan      html  css  js  c++  java
  • 「Bug」ubuntu 使用国内 apt 源构建 docker 时提示 hash 不匹配

    Bug 描述

    Bug 分析

    是 http 协议的缓存更新不及时,导致了 hash 值不匹配。

    解决方法

    根据上面给出的链接,我改用 https 协议的 apt 源,避免了缓存导致的这个 bug,具体的 dockerfile 如下:

    # Jenkins Slave 的配置
    # Dockerfile: https://github.com/jenkinsci/docker-jnlp-slave
    # dockerhub 使用 azure 镜像源加速下载(2020-04-05 最近这镜像站也抽风了)
    FROM dockerhub.azk8s.cn/jenkins/jnlp-slave:4.0.1-1
    LABEL maintainer="Ryan<ryan4yin@outlook.com>"
    
    # apt 镜像源的 host(三选一)
    ## 阿里云镜像速度快,而且稳定
    ENV APT_SOURCE_HOST="mirrors.aliyun.com"
    ## 清华镜像源,有时会停机维护(备选)
    # ENV APT_SOURCE_HOST=mirrors.tuna.tsinghua.edu.cn
    ## 中科大源,有时会停机维护(备选)
    # ENV APT_SOURCE_HOST=mirrors.ustc.edu.cn
    
    
    RUN echo "0. 设置 apt 使用镜像源,然后 update" 
        && sed -i "s@(deb|security).debian.org@${APT_SOURCE_HOST}@g" /etc/apt/sources.list 
        && cat /etc/apt/sources.list 
        && apt-get update --fix-missing 
        # 安装 https 协议需要的依赖
        && apt-get install -y --no-install-recommends 
            ca-certificates apt-transport-https 
        # 切换成 https 协议
        && sed -i "s@http://@https://@g" /etc/apt/sources.list 
        && echo "1. 安装需要的依赖" 
        && apt-get install -y --no-install-recommends 
            build-essential vim curl wget git
    
    # and so on
    

    解释一下,就是先使用 http 镜像源安装好 ca-certificates apt-transport-https 这两个依赖项,它们是使用 https 源的必备依赖。
    第二步是使用 sed 将 http 源修改成 https,这样就避免了 http 缓存导致的 hash mismatch 问题了。

  • 相关阅读:
    Lightmaping
    Android内存回收机制
    基本光照模型简单实现
    Pass的通用指令开关
    使用Depth Texture
    使用替换shader渲染
    Windows下安装Oracle12C(一)
    SpringMVC文件上传基础
    Spring集成线程池
    《经久不衰的Spring框架:@ResponseBody 中文乱码》(转)
  • 原文地址:https://www.cnblogs.com/kirito-c/p/12515566.html
Copyright © 2011-2022 走看看