Posts

Showing posts from January, 2026

Docker V/S Virtual machine

 There are different layers in an OS (windows, linux, mac) like  - Application Layer (MS word, ppt, sheet) - Host OS Kernel  - Hardware  Docker can only virtualize the application layer, whereas a VM can virtualize both application and host OS kernel. hence docker is less overhead and lightweight compared to a VM. Docker has a disadvantage that is, it was initially made for linux machines, so most of the images present on docker are mostly linux based. A VM is compatable that is it can be run on any OS.  If docker is built for linux systems and the images are linux based images, how are we (windows or mac) able to run them? The answer is docker desktop. The docker desktop adds a light weight hyper visor layer that internally uses a lightweight linux distribution.Hence we are able to run them.

Docker Image and Commands

Image
 This is similar to the concept of class and object in OOPS. Docker Image is an executable file that has the instructions on how to build a container. It provides a blue print just like a class.  Images take less space while containers take more space. COMMANDS: visit dockerhub for images. -> docker pull IMAGE_NAME    This command pulls and downloads the image. Ex: docker pull hello-world We can verify if the image exists on docker images by running the command, -> docker images To check all the containers available, -> docker ps -a There are states of container, they are running and exited . Exited state says that the container is present but it's not currently running. To build and run containers we use the command, -> docker run IMAGE_NAME -> docker run -it IMAGE_NAME -it refers to interactive mode, where we can access the container from terminal (take input and output). To check containers that are running, -> docker ps After running, ...

Why do we need Docker?

 If you have developed an app with a specific version of dependencies that are required to run the app, the same version of dependencies may not have been installed on the other teammates system. This situation might rise a conflict and the app would run on your system but not on the team member's. To solve issues like this, we use Docker. Docker is a single unit that contains the application along with all the dependencies. It is a platform that helps us build containers.  This container can be shared on any OS and the team members donot need to install the dependencies as they are shared through the container. Container is more like a standardized way to share our application. Characteristics of a container: - A container is portable ( can be shared) - Containers are lightweight (easy to build / update / destroy) - Containers allow us to build different applications on different versions of the same technology or same dependency. If we want to build two applications that use...