I have a Dockerfile that first copies over some common configuration files, then does more app specific things:
FROM postgres:9.4
COPY etc /etc
RUN apt-get update \
&& ...
...
From a clean slate, this works great. And if I modify files in the etc directory, docker picks up the change and invalidates the cache, rebuilding the image.
But if I’ve already cached this step before, and then I add new files to the etc directory (without modifying any existing ones), docker doesn’t detect that the cache needs to be invalidated:
Step 3 : COPY etc /etc
---> Using cache
---> 462e62492471
Which means my build will succeed, but the new files wont be present.
Is this a bug, or is there something about Docker image caching that I’m not understanding?
Note that the files I added were all directories (which themselves contain files), so perhaps the checksum that is computed for a COPY’d directory is not doing a recursive check.
Thanks!