使用apt-get在代理之后构build一个docker文件

我试图RUN apt-get -y install python在代理背后RUN apt-get -y install python ,如下面的dockerfile所示:

 FROM ubuntu:16.04 RUN \ http_proxy=http://exampleproxy.com:80 \ apt-get -y update && \ http_proxy=http://exampleproxy.com:80 \ apt-get install -y python python-dev python-pip python-virtualenv RUN \ http_proxy=http://exampleproxy.com:80 \ rm -rf /var/lib/apt/lists/* RUN pip install --upgrade pip --proxy=http://emea-proxy.uk.oracle.com:80 ADD . /code WORKDIR /code RUN pip install -r requirements.txt --proxy=http://exampleproxy.com:80 ENTRYPOINT ["python", "python_file.py"] 

我必须在第一次运行中指定两次代理,否则代理不会继续进行apt-get install

我不能使用ENV因为它会影响程序(它运行/获取代理内的文件,如果我将代理指定为环境variables,将会不正确地下载)。

当我尝试build立我的文件时,我得到这个错误:

 Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? The command [...]returned a non-zero code: 100 

我已经考虑了docker层caching,并在构build映像时使用--no-cache 。 所以apt-get update应该每次都运行。

谢谢阅读 :)