Have you ever encountered an issue where your code works on your machine but does not work on another machine? Most of you should probably have faced this issue.But what if we could remove this platform dependency somehow. This is where docker comes into play.
What is Docker?
Docker is a platform as a service (PaaS) that uses OS-Level Virtualization to deliver software packages in containers which helps to build, test and deploy an application in any environment.
Docker Ideology
Let's say we want to assemble a car in one country, For that, we have to bring all the required parts from another country. If those components are shipped as individual components, sometimes some of them might get lost, leaving us with an uncompleted car. But if the person who sends, could send them packing the components into the container, the risk of losing the parts is minimum.
It is the same in the software development world, If the software developer could send the source code with all the dependencies and libraries, it ensures that the code works as expected in another environment, Docker enables this through containerization.
Containers VS VMs
Let's see the differences briefly..
Virtual Machines
In simple terms, VMs are emulations of physical machines. VMs provide hardware-level virtualization and have their own Operating System aka OS. To communicate with the host it uses a software layer called Hypervisor.
Containers
Containers are more lightweight than VMs. Provides OS-level virtualization and share the host OS. Since it does not have to spin up an entire VM to run Boot Up times are generally around milliseconds.
Docker Terminology
Before getting an idea about the Docker workflow, it is better to know the terminology. 👇
Dockerfile: File that contains the instructions to build a Docker image.
Docker Image: Has all the instructions to build a Docker container. Also it contains application code, libraries, tools, dependencies and other files to make the application run.These images can be stored in Docker Hub which is a remote repository.
Docker Container: A runtime instance of a Docker image.
Docker Workflow
Must Know Docker Commands
-
docker images
: list down all the docker images -
docker ps
: list down all running docker containers -
docker ps -a
: list down all the docker containers -
docker start <container name or id>
: start a container -
docker stop <container name or id>
: stop a container -
docker run <image name or id>
: create a container using a docker image
Wanna know more? 👉 References
Useful Resources
Thanks for reading.. 🙌
Top comments (0)