docker-compose不下载requirements.txt文件的附加内容

我有一个在Docker中运行的Django项目。 当我将一些软件包添加到我的requirments.txt文件中时,在运行docker-compose时它们不会被下载

以下是我的Dockerfile中的相关命令:

ADD ./evdc/requirements.txt /opt/evdc-venv/ ADD ./env-requirements.txt /opt/evdc-venv/ # Active venv RUN . /opt/evdc-venv/bin/activate && pip install -r /opt/evdc- venv/requirements.txt RUN . /opt/evdc-venv/bin/activate && pip install -r /opt/evdc-venv/env-requirements.txt 

看起来docker正在使用我的requirements.txt文件的caching版本,因为当我将shell放入容器时,/opt/evdc-venv/requirements.txt中的requirements.txt文件不包含新的包。 有什么办法可以删除这个caching版本的requirements.txt?

  • 开发操作系统:Windows 10
  • Docker:17.03.0-ce
  • docker构成:1.11.2

docker-compose up不会构build一个新的图像,除非你有你的Dockerfile定义的build部分,你传递了--build参数。 没有这个,它会重用现有的图像。

如果您的docker-compose.yml不包含构build部分,并且您使用docker build ...构build了您的映像,那么在您重新创build映像之后, docker-compose up会重新创build受影响的容器。