也许您可以尝试以下方法:
调用之前
RUN,
ADD.env文件进入图像
ADD proxies.env proxies.env
然后为您的RUN语句添加前缀:
RUN export `cat proxies.env` && echo "FOO is $FOO and BAR is $BAR"
这将产生以下输出:
root@armenubuntudev:~/Dockers/set-env# docker build -t ashimoon/envtest .Sending build context to Docker daemon 3.584 kBSending build context to Docker daemon Step 0 : FROM ubuntu ---> 91e54dfb1179Step 1 : ADD proxies.env proxies.env ---> Using cache ---> 181d0e082e65Step 2 : RUN export `cat proxies.env` && echo "FOO is $FOO and BAR is $BAR" ---> Running in 30426910a450FOO is 1 and BAR is 2 ---> 5d88fcac522cRemoving intermediate container 30426910a450Successfully built 5d88fcac522c



