Docker Image Size – Does It Matter?
Blog post from Semaphore
Docker image size is often perceived as important due to misconceptions about disk space and upload efficiency, but the primary concern should be the size of frequently changing layers, which impact both disk usage and upload times. Docker images consist of reusable layers, meaning that the overall image size doesn't directly correlate with disk space consumption, as shared layers among images mitigate this. Similarly, when uploading or downloading Docker images, only new or modified layers are transferred, reducing the impact of overall image size. In continuous integration and delivery (CI/CD) environments, using a solution with an integrated Docker registry, like Semaphore, can eliminate inefficiencies by caching image layers. To create manageable Docker images, the focus should be on designing Dockerfiles that minimize the size of frequently changing layers by organizing files based on how often they are modified. Although smaller Docker images are generally preferred for reducing the attack surface, their construction is more critical than their total size due to the amortization of initial upload/download hits over time.