最佳答案
在 Dockerfile 中,我有一个安装 requirements.txt
的图层:
FROM python:2.7
RUN pip install -r requirements.txt
当我构建 docker 映像时,它会运行对该文件所做的任何更改的整个流程 无论如何。
如何确保 Docker 只在文件发生更改时运行 pip install -r requirements.txt
?
Removing intermediate container f98c845d0f05
Step 3 : RUN pip install -r requirements.txt
---> Running in 8ceb63abaef6
Collecting https://github.com/tomchristie/django-rest-framework/archive/master.zip (from -r requirements.txt (line 30))
Downloading https://github.com/tomchristie/django-rest-framework/archive/master.zip
Collecting Django==1.8.7 (from -r requirements.txt (line 1))