【发布时间】:2017-09-27 09:10:15
【问题描述】:
我正在尝试为我的 python 项目设置 docker,它使用虚拟环境并在 requirements.txt 中定义了一些依赖项。
我也设置了docker-compose,它使用Dockerfile 使用命令docker-compose up --build 构建我的项目映像
我的 Dockerfile:
FROM ubuntu:16.04
FROM python:3.5
MAINTAINER ****
ADD . /core-proejct
WORKDIR /core-project
RUN pip3 install virtualenv
RUN . /bin/activate
RUN pip install -r requirements.txt
所以,每次我尝试构建映像时,它都会从requirements.txt 安装所有 pip 模块。
无论如何我可以缓存 pip 模块并在构建图像时使用缓存的版本。
【问题讨论】:
标签: python-3.x docker pip docker-compose dockerfile