1.Why are containers lightweight?
Containers are low in size because it shares the resources from the host OS. The container has the minimum binaries and libraries that are required to run the commands.
For example, suppose you are building an image of Ubuntu. Though it is an operating system whose actual size is close to 2.3 GB, you can see in the below screenshot the size of the Ubuntu base image size is around 25 MB. So the container base image is almost 100 times less than the size of the Operating System.
It shares the host operating system's kernel and libraries, while still providing isolation for the application and its dependencies. This results in a smaller footprint compared to traditional virtual machines, as the containers do not need to include a full operating system.
Additionally, Docker containers are designed to be minimal, only including what is necessary for the application to run, further reducing their size.
2.Docker LifeCycle
Just to refresh on what Docker is:
Docker is a containerization platform that provides an easy way to containerize your applications, which means, using Docker you can build container images, run the images to create containers and also push these containers to container registries such as DockerHub, Quay.io and so on.
We can use the below image as a reference to understand the lifecycle of Docker.
DockerHub contains all the open-source images for a container. We can push or pull the image from DockerHub to our system. It saves the image in Docker Engine, and Docker Engine is physically present in our system.
We can check the list of images by using "docker image" command. You can build a container from the image(s) by using "docker run" command.
Below are the important stages of Docker:
RUN, STOP, DELETE.
When you run the image, it helps to run a container.
And a container can be either in a running stage, stop stage or deleted stage.
docker run -> Runs container from docker images
docker stop -> It will stop a running container. If you want to delete an image, you need to stop the container before deleting the dependent image.
docker push -> push the container image to public/private registries to share the docker images.
docker build -> builds docker images from Dockerfile.
If this post was helpful, please follow and click the ๐ button below to show your support.
_ Thank you for reading!
_Sudipa