【发布时间】:2016-07-04 09:16:11
【问题描述】:
我稍微修改了this Dockerfile 以支持我的特定用例:我需要指定我自己的PyPi 服务器,我们将在其中发布我们的内部库。这通常可以通过指定pip.conf 文件或将命令行选项传递给pip 来实现。
我正在尝试这个:
FROM python:3.5
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ONBUILD COPY requirements.txt /usr/src/app/
# 1st try: set the env variable and use it implicitely. Does not work!
# ENV PIP_CONFIG_FILE pip.conf
# ONBUILD RUN pip install --no-cache-dir -r requirements.txt
# 2nd try: set once the env variable, just for this command. Does not work!
# ONBUILD RUN PIP_CONFIG_FILE=pip.conf pip install --no-cache-dir -r requirements.txt
# 3rd try: directly configure pip. Works, but these values should not be set in the Dockerfile!
ONBUILD RUN pip install --index-url http://xx.xx.xx.xx:yyyyy --trusted-host xx.xx.xx.xx --no-cache-dir -r requirements.txt
ONBUILD COPY . /usr/src/app
我的pip.conf很简单,在Docker外面使用也可以:
[global]
timeout = 60
index-url = http://xx.xx.xx.xx:yyyyy
trusted-host = xx.xx.xx.xx
链接:
我有以下问题:
- 为什么
ENV不起作用? - 为什么在
RUN命令中显式设置变量不起作用? - 是
ONBUILD还是RUN的问题?
【问题讨论】:
标签: python docker dockerfile