Optimizing the size of the image
Introduction
Peace to you all , Here is the Link to my previous blogs, Where I have posted about Docker, Containers and DevOps.
This is Day 10 of documenting my DevOps journey .
This blog focuses on Optimizing the size of the image.
Getting Started
The base OS image like Debian, which is a solid Linux distribution , has a size of about 200MB for the image. We have to make our images as small as possible when moving to production since the image size plays a vital role in production environment’s cost and also size.
Reducing it as much as possible without deteriorating any major functionality is very much important.
There comes Alpine , which is based on Alpine Linux.
Alpine
Alpine Linux is one of the Linux distributions .
The official website for alpine can be found here. The image is comparatively very much smaller but has access to package repositories which are totally sufficient.
They weigh so much less compared to normal Linux distributions like Debian .
Comparing with plain Debian
Let us take a Debian Image and Alpine image from DockerHub.
Pull a Debian docker image,
docker pull debian
Now , Pull a alpine docker image,
docker pull alpine
Now , Try running docker images.
docker images
We can clearly the huge difference in the size of the two images .
Note: The services provided by Debian and the services provided by alpine is totally not considered and just for example , we have compared the sizes .
But generally, If we don’t have any such specific requirements for a docker image , Alpine is a very good start.
Performance
Speaking of performances of Alpine , Again , we can’t be 100% sure that One OS is better than the other , But with some reports suggest, Debian has greater performance when compared to Alpine ,when tested on a large scale . They have their own pros and cons.
So , Alpine can be a good start if we want the image to be small and the scale to be small but over time when the demand arises , it is better to analyze different other OS to acquire the performance we need , if not achieved with alpine or any other Base image we choose.
Conclusion
It’s all about requirements to optimize an image and also get a better performance . Before taking up any OS as base image it is better to analyze each and every thing a base OS is capable of and how it’s performance is .
Alpine can be a good start as the image size is very much lower but over time we must also think about the performance, where some other OS can be efficient.
Nowadays many image comes with a alpine version which makes it so small , which can also be tried.
What have we done
We analyzed Debian vs Alpine , Learnt how an OS can be selected as base image for building our image.
Also , Alpine has been widely used in other distributions with a alpine tag, which is smaller than the regular .
For example: Checkout the node docker image page , There will be different versions of node along with many alpine versions.
See you Tomorrow
Okay . So hold on, stay with me as we get to know docker more and DevOps even more.
Okay Then , Will get back Tomorrow with more!
Peace be upon you!