編寫了一個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-8-jre RUN apt-get install -y openjdk-8-jre --fix-missing #安裝其他使用的包 RUN apt-get install -y tar ubuntu-make autoconf automake build-essential libass-dev libfreetype6-dev \ libsdl1.2-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:100 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 libllvm3.8 amd64 1:3.8-2ubuntu4 [10.3 MB] Err:100 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: 100
這個問題困擾了好長一段時間,之後嘗試了一下只使用main的源,其他的刪除掉,jre能安裝成功,但是後面的那些包又找不到。所以最後只能使用以下的work around方案把映象做成了:
FROM ubuntu:16.04 #openjdk-8-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-8-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.2-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