How does Docker know when to use the cache during a build and when not?

前端 未结 2 1174
温柔的废话
温柔的废话 2020-12-24 01:41

I\'m amazed at how good Docker\'s caching of layers works but I\'m also wondering how it determines whether it may use a cached layer or not.

Let\'s take these build

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 02:27

    It's because your package.json file has been modified, see Removing intermediate container.

    That's also usually the reason why package-manager (vendor/3rd-party) info files are COPY'ed first during docker build. After that you run the package-manager installation, and then you add the rest of your application, i.e. src.

    If you've no changes to your libs, these steps are served from the build cache.

提交回复
热议问题