Docker has a cache, which is great, but all I see in the "docker build" output is either:

---> Using cache

or the output of the command (which implies it's not using the cache).

After one step in my Dockerfile (a COPY), it clearly doesn't use the cache. But I'm fairly certain nothing has changed in the folder that it's copying. (It's our application, and I run into the no-cache case even when I deploy twice in a row, for example.)

Is there any way to get Docker to tell me what it thinks changed?

I know Docker used to check timestamps for this, but that was fixed in Docker 1.8, and I'm on Docker 1.9.x here.

  • Please post your Dockerfile – Joel E Salas Jan 9 '16 at 4:55
  • 2
    @JoelESalas: I don't understand your request. Something as simple as FROM ubuntu:14.04 MAINTAINER me COPY /app/ /app/ will demonstrate this. And I'm not going to post my entire source code and infrastructure. – Timmay Jan 11 '16 at 21:36
  • 1
    Besides, even if looking at the Dockerfile could help, the question was how do I diagnose such problems. I don't want somebody else to look at my config and tell me the answer. I want to know what tools exist to help solve the problem. – Timmay Jan 11 '16 at 21:38
  • How sure are you that nothing is changing in that directory? – Joel E Salas Jan 12 '16 at 0:11

Use binary search, with .dockerignore.

Add half your files to .dockerignore, and build the container. If it uses the cache for the COPY step, then you know the changed files are in the set you ignored, otherwise you know it's in the other half. Repeat this test with the set of files that has the change, until it's just one file/folder.

(Dear lazyweb: figure out some way to extend Docker to make this less painful!)

|improve this answer|||||
  • 3
    Sounds an okay approach for debugging something locally, thanks. In my case, I'm currently trying to debug the Docker cache in a CI environment, and I'm a bit bummed that I can't seem to find any way to make the Docker build more verbose =/ – elias May 3 '19 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.