Skip to content

git clone inside Dockerfile RUN uses cached layers

It might be possible to avoid this (but still have layer caching) by using an ADD with the repository tar.gz url.

Advantages:

  • The url will download a file and checksum against the layer cache to determine if there is new content, instead of just relying on the hash of the command itself.

Disadvantages:

  • Network load since every build will trigger a download.
  • Using rm -rf on the cloned repository will not reduce the size since ADD will be its own layer.