Docker Build 阶段的代理设置
Docker 在构建阶段,如果要通过代理下载文件的话,需要使用 arg 命令,如下所示 Dockerfile :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
FROM ruby as ruby
ARG https_proxy=https://192.168.1.2:8080
ARG http_proxy=http://192.168.1.2:8080
WORKDIR /tmp
RUN apt update \
&& apt -y -q upgrade \
&& apt install -q -y --no-install-recommends --no-install-suggests \
ruby-dev unzip wget tar openssl xvfb chromium lsof \
chrpath libxft-dev libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \
&& wget https://chromedriver.storage.googleapis.com/2.44/chromedriver_linux64.zip \
&& unzip -o chromedriver_linux64.zip -d /usr/local/bin \
&& rm -f chromedriver_linux64.zip \
&& wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 \
&& tar -xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 \
&& mv phantomjs-2.1.1-linux-x86_64 /usr/local/lib \
&& ln -s /usr/local/lib/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin \
&& rm -f phantomjs-2.1.1-linux-x86_64.tar.bz2 \
&& rm -rf /var/lib/apt/lists/*
COPY Gemfile ./
RUN gem install bundler \
&& bundle install
https_proxy, http_proxy 更改为实际的代理地址。
本文由作者按照
CC BY 4.0
进行授权