在dockerfile中自定义ONBUILD环境
我稍微修改了这个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
链接:
-
Dockerfile
的ENV 在这里被logging - 这里logging
pip
configuration
我有以下问题:
- 为什么
ENV
不工作? - 为什么
RUN
命令中variables的显式设置不起作用? - 那些
ONBUILD
问题,或者是RUN
?
ONBUILD
指令为图像添加一个触发器指令,稍后将该图像用作另一个构build的基础。
从文档 :
在1.4之前,
ONBUILD
指令不支持环境variables,即使与上面列出的任何指令结合使用。
使用docker工具1.4+,尝试(如问题15025所示 )
ONBUILD ENV PIP_CONFIG_FILE pip.conf
- 每次都必须设置eval $(小船env)。 无法连接到Docker守护进程。 docker守护程序是否在这个主机上运行?
- Heapster无法从Kubernetes集群上的Kubelet获取容器统计信息
- Travis Docker Image缺lessPython 3.5
- 把python-pip放在CentOS的docker镜像上?
- 解决docker问题 – 编写不同的客户端服务器会导致新的错误,说明降级Docker SDK for Python的版本
- Docker容器在docker-py库中等待/运行时间
- pipe道数据exec_create&标准input/标准输出
- PyCharm远程解释器:无法执行Docker的Python二进制文件
- 基本图像导致通过Jenkinepipe道在我的泊坞窗文件caching半身像
- 如何在Docker容器中运行psutil?
- 在dockerfiles中将哪个Pythonvariables用作基础映像?