【发布时间】:2019-08-09 16:28:45
【问题描述】:
我正在使用 docker compose 来构建 Python 项目的堆栈。这是处理需求的dockerfilesn-p。
# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip install --no-cache-dir -r /requirements/production.txt \
&& rm -rf /requirements
使用该配置,我可以缓存需求,但是当我修改 production.txt(例如更新单个包)时,Docker 会重新安装所有内容。
我知道 Docker 需要创建一个新容器,但有没有办法避免重新安装所有内容而只安装必要的内容?
【问题讨论】:
-
为什么不拥有不需要不断更新/安装的最常见软件包的基本映像,然后仅在需求中指定需要更新/重新安装的软件包?
标签: python docker pip docker-compose