Optimizing image size
The image we created above consumes approximately 9 GB of memory. When we are building images on a container host, the image size becomes an important factor when we want to move the image from one host to another or while uploading to a registry. It is very important to learn about authoring Dockerfiles that dramatically reduce the size of the image.
The first step to reduce the image size is to group the RUN commands. As we have seen, each RUN command turns into a layer, if we can reduce the number of RUN commands, we should be able to reduce the number of layers. For example, let us compare two Dockerfiles which install Redis on Windows Server Core. The following file contains instructions spread out into multiple ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access