Docker : The Dev Container


What is Docker?
Docker is a containerization platform that packages applications into containers to run without any problem.
Before Docker/Containerization tool?
Before this for every application we use one whole server , which is so costly and difficult to maintain ,
so VMware solved that problem by using Virtual machines .
Even in Virtual Machines there are many flaws like,
Dedicated OS for each application
Not fast enough
Dedicated storage
Dedicated hardware & so on…..
Before Tools like Docker used in market , we have a Problem “IT works on my machine“.
Docker solved All the Problems.
Containers
Containers are collection of thing we need to run our applications.
It contains
Base OS (mostly light weight OS)
Infrastructure
Container Engine
Libraries needed to run the application
Applications
Virtual Machines VS Containers
In Virtual Machines we need multiple OS to run multiple Application
But In Containers we just one OS for multiple Applications .
We use Container engine to run Multiple apps in single OS.
Installation
Windows
Install Docker Desktop + WSL from ( Windows OS ).
Mac
Install Docker Desktop from ( Mac OS ).
Linux
Install Docker Engine not Docker Desktop from ( Linux ).
Parts of Docker Desktop / Docker
Docker Runtime.
Docker Engine.
Docker Orchestration.
Docker Runtime
Basically allow us to Start/stop the container.
runC (low level).
containerD.
getting Data /internet.
manage runC.
Docker Engine
It contains Docker CLI , Rest API , DockerD(server) , Daemon .
Rest api is used to bridge between Sever and CLI .
Docker Orchestration
This manages the Containers .
Kubernetes is one of the orchestration tool.
Docker Images
Its a file that contains all the instructions to create a container for our applications.
We can Create Docker Images using Dockerfile.
We can Create Container using Docker Image.
Docker CLI commands
// docker run image-name
docker run hello-world
docker run - it will run the docker image if it is locally available or its download it from Docker Hub
docker images
docker images - it will return the available images locally
// docker pull image-name
docker pull ubuntu
//docker pull image-name:tag/version
docker pull ubuntu:16.01
docker pull - it will download the image from the Docker Hub
Note : if tag is not defined it will automatically download latest version
docker run -it ubunut
docker run -it ubuntu - its runs the image in interactive environment
docker ps
docker container ls
return all running containers
docker ps -a
return all the stopped containers
//docker rm container-id
docker rm 4f2304iua402j
docker rm - it will remove/delete the container
//docker rmi image-id
docker rmi 4239u020jasf9
docker rmi - it remove the docker image
Docker Layers
A Docker image is collection many files/layers
Each layers have a unique hash values as ID using “SHA256” representation.
If Two Docker images have same layer/file it will not download again from Docker Hub. it will use the already installed one for both images.
How to Create a Docker Image?
create a file named “ Dockerfile “ in the requires directory/folder.
write create instruction to run the container using Linux cmd’s.
Must declare a Base image(OS) in the file.
Write the instructions need to run the applications.
save the file.
//docker build -t image:tag/version path
docker build -t test-image:1.01 .
this command will build a docker image with file the mentioned directory , i mention “.” to use the same dir.
Is Docker needed for SDE roles in IT field today ?
Answer is Yes and No , because Docker is tool used by Devops people but in this modern time its will be useful to learn docker and Kubernetes to standout form the crowd while Appling for a job. Its not at all compulsory for Software Developer Role still today
Learning daily will make a big difference in a long run .
-rakeshraj .
Subscribe to my newsletter
Read articles from N Rakesh Raj directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
