3

I've got problem with my Dockerfile. After building an image it is pushed to repository as cache-image, so on next builds I can pull it and use with --cache-from.

Problem is that build stops using cache after first ADD command.

Step 20/30 : WORKDIR $PROJECT_PATH
---> Using cache
---> d79e2ba28d96
Step 21/30 : ADD requirements $PROJECT_PATH/requirements
---> 6261bb0bd3e6
Removing intermediate container 26707f4107c9

I ran both images (cache and built one) and checked content of requirements directory, they're both identical. Whole build is done on Bamboo worker.

2

Check the image history of your two images with docker image history. Pay careful attention to the sha256 checksum of the files being added on the ADD line. Docker performs a checksum on the files, including some of the metadata on these files, so a single byte change or a permission update will result in a cache miss.

Once you've checked this, if it is not your issue, please update the question with the pull command, the build command and full output, and the history command on both images.

Side note: you likely want to use COPY instead of ADD unless you are pulling remote files or extracting a tar file into a directory.

  • I had the same issue. The sha256 of the file in the image and on the filesystem matched, though that doesn't match what shows up in the history with a file: prefix. The problem was the chmod on the file (apparently GitLab CI checks out files as 666 no 644). – remram Jan 29 at 16:18

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.