Docker Introduction
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
What is Docker ?
Docker is a tool and a platform to simplify the way we create apps and deploy them. Its based on containerization and since its more light weight, cuts across platforms it is being used all across the industry. It allows :-
- To create docker images where we store our app content
- To publish the docker images – host our app content for consumption
- To run the app as docker container – run application as containers
What is Container?
Container is an instance of our app – but in an isolated environment – with its own process id map, network, mount point – by a containerization platform such as docker.
Benefits of Docker?
- Saves Time – Time taken to develop/deploy reduced, also less OS related issues in deployment/testing – so debugging time is less
- Saves resources – as its light weight, so can make more optimal use of system and we can have more no. of apps in same server
- Saves cost – Since in less resources, able to achieve more
Docker Architecture
- Rough Breakdown :- Docker Client that interacts with Docker Engine (Docker Server + Containerd) that down the line talks with kernel
- Docker Client is used by people such as us – to issue commands to create, publish and run containers
- Docker Engine (Docker Server + Containerd) – is the one which takes our commands and is a constantly running process that interacts with host machine’s OS – Kernel to create infrastructure required for a container namely a separate pid map, network, mount point, user – and facilitates the isolated environment required for it.
- In case of image creation it manages – creation of a root filesystem that has content necessary for app.
Container lifecycle
We can start a container from image – stop a running container – restart it again from the stored image – and pause it also. Since all the actions are getting stored in the root filesystem for it
How Docker works !
Docker forms a layer over our machine’s OS and interacts with the Kernel to create an isolated environment for each app container.
Why ? Since normally OS allows only 1 process id map and 1 network, filesystem – but for an isolated environment in same OS we can require multiple of these – so Docker needs to be that person in the middle negotiating with the OS for it.
That ways I can run 2 node.js app servers running on port 8080!
Why its better than VM ? Reduces redundant layer of the guest OS – as for running 2 node.js servers there – we needed 3 OS’s plus Hypervisor which was heavy weight!
1 major difference also is it uses root filesystems not boot filesystems like VMs – since to run Docker Engine we don’t need another Kernel. That adds to its light weight nature
Its also a platform the share the apps, DBs, OS-filesystems through the docker hub registry – which now other platforms are making including Cloud Providers like AWS, Azure, GCP.