hub-feedback icon indicating copy to clipboard operation
hub-feedback copied to clipboard

Docker Hub Automated builds do not cache layers

Open CL0SeY opened this issue 8 years ago • 3 comments

Builds are slower on Docker Hub compared to building the same Dockerfile on a static same host. This is especially evident if bringing in a large number of dependencies (e.g. node npm install).

It would be good if layers from previous build could be re-used across runs. This would reduce the amount of CPU time builds take, and reduce bandwidth requirements.

CL0SeY avatar Apr 27 '16 07:04 CL0SeY

I suspect that this is partially a feature, not a bug.

Consider a layer such as

RUN apt update

If you build this locally, you will notice that this layer gets cached. But the command is non-deterministic. After a couple of days, you do NOT want to cache this any longer, because you want your images to include the newer, more up-to-date package lists.

Locally, it is not a problem. You just tell docker build not to cache this time. For automated builds on docker hub, you would need a way to specify how often the cache should get invalidated.

I presume that the developers of Dockerhub did not want to deal with such problems and therefore decided to simply never cache.

I agree that it is annoying, though :)

KonstantinSchubert avatar Nov 21 '17 23:11 KonstantinSchubert

It takes me 15 minutes after every little push for my project to be built, because the node npm packages keep getting installed from scratch over and over again. So I take it I should stop using Docker Hub and created builds myself manually if I wanted layers to be cached :(

amcsi avatar Jul 17 '18 13:07 amcsi

still not caching layers ?

SergeyKapshuchenko avatar Oct 17 '22 11:10 SergeyKapshuchenko