编写了一个Dockerfile,主要目的是构建一个镜像,镜像默认安装了openjdk-1.8-jre,还有另外一些包(这些包里面有dev版本的,也有release版本的),Dockerfile的内容大致如下:

FROM ubuntu:16.04

RUN echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse" > /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse" >> /etc/apt/sources.list \
&& apt-get update #安装openjdk--jre
RUN apt-get install -y openjdk--jre --fix-missing #安装其他使用的包
RUN apt-get install -y tar ubuntu-make autoconf automake build-essential libass-dev libfreetype6-dev \
libsdl1.-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev libx264-dev libfdk-aac-dev yasm --fix-missing

这段Dockerfile build没有通过,在3台机器(分别对应不同的网络环境)上测试过,只有其中一个环境是能build成功,报错的两个环境都是以下错误(有差异的原因现在也没搞清楚,搞了两三个星期了,很晕)

Get: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 libllvm3.8 amd64 1:3.8-2ubuntu4 [10.3 MB]
Err: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 libllvm3.8 amd64 1:3.8-2ubuntu4
Hash Sum mismatch
...省略了中间一部分的日志... Unable to correct missing packages.
E: Failed to fetch http://mirrors.aliyun.com/ubuntu/pool/main/l/llvm-toolchain-3.8/libllvm3.8_3.8-2ubuntu4_amd64.deb Hash Sum mismatch E: Aborting install.
The command '/bin/sh -c apt-get install -y openjdk-8-jre --fix-missing' returned a non-zero code:

这个问题困扰了好长一段时间,之后尝试了一下只使用main的源,其他的删除掉,jre能安装成功,但是后面的那些包又找不到。所以最后只能使用以下的work around方案把镜像做成了:

FROM ubuntu:16.04

#openjdk--jre使用了updates源之后报hash sum mismatch的错误,
#只能使用main才能安装成功,这个问题没有找到根本原因,暂时使用此解决方式
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse" > /etc/apt/sources.list \
&& apt-get update RUN apt-get install -y openjdk--jre --fix-missing RUN echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse" > /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse" >> /etc/apt/sources.list \
&& apt-get update RUN apt-get install -y tar ubuntu-make autoconf automake build-essential libass-dev libfreetype6-dev \
libsdl1.-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev libx264-dev libfdk-aac-dev yasm --fix-missing

源设置导致Docker镜像构建失败的更多相关文章

  1. Docker镜像构建(五)

    Docker 镜像介绍 Docker镜像构建分为两种,一种是手动构建,另一种是Dockerfile(自动构建) 手动构建docker镜像 案例:我们基于centos镜像进行构建,制作自己的nginx镜 ...

  2. 4、Docker 镜像构建

    Docker 镜像构建 构建分为两种 手动构建 自动构建dockerfile 手动构建 首先启动一个Centos 容器,然后在容器中安装一个nginx [root@node ~]# docker ru ...

  3. Docker镜像构建原理解析(不装docker也能构建镜像)

    在devops流程里面 构建镜像是一个非常重要的过程,一般构建镜像是写dockerfile文件然后通过docker client来构建的image. docker client 会先检查本地有没有im ...

  4. sqler sql 转rest api 的docker 镜像构建(续)使用源码编译

    sqler 在社区的响应还是很不错的,已经添加了好多数据库的连接,就在早上项目的包管理还没有写明确, 下午就已经有go mod 构建的支持了,同时也调整下docker 镜像的构建,直接使用git cl ...

  5. Spring Boot 2.6.0正式发布:默认禁止循环依赖、增强Docker镜像构建...

    昨天,Spring官方正式发布了Spring Boot今年最后一个特性版本:2.6.0 同时,也宣布了2.4.x版本的终结. 那么这个新版本又带来了哪些新特性呢?下面就一起跟着DD来看看吧! 重要特性 ...

  6. Docker镜像构建

    一.简介 在构建容器化应用时,相当重要的步骤莫过于镜像制作,本文将介绍镜像制作方法以及镜像制作的建议.通常镜像的制作有两种方式: 使用现有的容器使用docker commit 生成镜像 使用Docke ...

  7. apisix网关-构建docker镜像构建及插件化开发

    高能劝退:lua开发,适合小白看!!! 前段时间有个项目,用的java程序做网关,压测tps只有1k多点,惨不忍睹. 后来公司有个大佬改用apisix做网关,tps飙升到1w多. 于是对神奇的apis ...

  8. Docker镜像构建的两种方式

    关于Docker里面的几个主要概念 这里用个不太恰当的比方来说明. 大家肯定安装过ghost系统,镜像就像是ghost文件,容器就像是ghost系统.你可以拿别人的ghost文件安装系统(使用镜像运行 ...

  9. Docker镜像构建的两种方式(六)--技术流ken

    镜像构建介绍 在什么情况下我们需要自己构建镜像那? (1)当我们找不到现有的镜像,比如自己开发的应用程序 (2)需要在镜像中加入特定的功能 docker构建镜像有两种方式:docker commit命 ...

随机推荐

  1. Understanding ABI Files

    [Understanding ABI Files] ABI files can be generated using the eosio-cpp utility provided by eosio.c ...

  2. Unity之AssetBundle打包

    AssetBundle Resources:表示U3D自动将资源打成一个AssetBundle包,所有放在Resources下的文件夹都会打成一个AssetBundle包,资源非常大,Resource ...

  3. java学习笔记(七):for循环

    java的for循环和c++的for循环类似 public class Test { public static void main(String args[]) { for(int x = 10; ...

  4. IO 、NIO、AIO

    Java 中的流 https://ifeve.com/java-nio-vs-io/

  5. Pains and Sickness 学习笔记

    Headaches can be very painful and can last for a long time. If you have a headache, your head hurts. ...

  6. tomcat7闪退

    问题是我昨天运行的好好的,今天加了些代码,tomcat7就会启动闪退.我把conf/server.xml中的<Context />去掉,tomcat又能正常启动! 那么问题出在哪里呢? 我 ...

  7. go语言 http学习

    net/http库学习 概念 处理器 处理器:拥有ServeHTTP方法的接口(任何类型) 签名:ServeHTTP(http.ResponseWriter, *http.Request) Respo ...

  8. centos 7 vim 保存文件 root 权限 及 使用

    vim打开文件时,没有用root账户,保存时才发现需要root权限.办法是在vim执行一下命令: :w !sudo tee % 未完待续

  9. How to configure Samba Server share on Debian 9 Stretch Linux

    Lubos Rendek Debian 13 June 2017 Contents 1. Objective 2. Operating System and Software Versions 3.  ...

  10. Mysql知识点个人整理

    1.概念 数据库:保存有组织的数据的容器. 表: 某种特定类型数据的结构化清单 模式:关于数据库和表的布局和特性的信息?(有时指数据库) 主键: primary key 一个列或一组列,其值能唯一区分 ...