Reducing Docker Image Size - Slimming vs Compressing
Pieter van Noordennen
Apr 05, 2021
We often get questions about the difference between compressing images and slimming images. Both are critical to having a happy and efficient development pipeline, but understanding the difference between them is important to have a high-performing and secure cloud-development process.
- Compressing is simply the act of making an image smaller, like zipping a file.
- Slimming is the process of optimizing your image so that it is performant, secure, and usable in all stages of the SDLC.
Compressing an image is a simple, automated, and basic task that can be handled at all stages of the CI/CD pipeline. The Docker executable even does this for you by default by producing a tarball of your container. Compressed images don’t run; their primary function is to move smoothly through the pipeline and reduce transfer costs and disk space.
When we talk about slimming images, we’re talking about a system of tools and techniques to optimize an image. Slimming an image results in a container that has only the code it needs to run and nothing more. This leads to better outcomes across all phases of development. This process is often manual and requires specialized knowledge.
Slimming an image also reduces the container size, but is a dynamic and use-case specific process. You may have a different slimmed image in your development environment than you do in staging or production.
Slim images are faster, more performant, and safer, as the act of slimming an image reduces the attack surface of a container. Slimmed images can also be compressed, usually with the same compression ratios of non-slimmed images.
Most developers today don’t know, and don’t have time to learn, how to dissect their Docker images, make smart optimizations, and get the right tooling to ship their containers safely and effectively.
At Slim.AI, we’re working on tools that automate the process of slimming and optimizing images. Interested in learning more? Check out the example library in our SlimToolkit (previously DockerSlim) open source project, or shoot us an email at firstname.lastname@example.org to request a beta invite.