Docker build: use http cache

2019-07-23 04:42发布

I have a step in my docker file that installs python requirements:

COPY req.txt /req.txt
RUN pip install -r /req.txt

I change req.txt and add/remove packages to/from it frequently and rebuild the image.

Is there a way for docker to use a http cache for downloaded files?

Please do not advise me to change my docker file to something else.

标签: docker
1条回答
SAY GOODBYE
2楼-- · 2019-07-23 04:52

I used to do this by build a second image, for example. You can build a basic image.

FROM python
RUN pip install -r req.txt

and build it with the following command:

docker build -t basic_python .

For now, if you want to build your really image, just simply do it with another docker file:

FROM basic_python
RUN ....
CMD ....
查看更多
登录 后发表回答