Docker Basic Notes

Basics Of OS & Docker

You Can Revise Docker Concepts From This Blog

A user runs a program, it can only be run on an operating system and an operating system runs on the top of a hardware.

Without any O.S you can’t run any program, without running any program you can’t do anything in your O.S

OS -> Install in 30 minutes + Boot + Login == Almost 30–40 Minutes to launch a single Operating System.

But in the Real World, we need this within a few seconds
Install OS → Run Program → Testing or Building → Destroy/Terminate OS

We Need Faster Deployment in today’s competitive world, That’s why Containerization Technology comes into the picture.

Docker installs the Operating System in One Second with all the Libraries & Binaries.

There are mainly 4 Ways:-

  1. If you launch any O.S on top of your Hardware:- it is known as Operating System.

  2. If you launch any O.S on top of Virtualization:- it is known as Virtual Machine or guest machine.

  3. If you launch any O.S on top of Cloud Technology:- it is known as instance.

  4. If you launch any O.S on top of Docker:- it is known as a container.

In Storage a written code in a file is called a Program, When we run that program it becomes a Process.

docker pull ubuntu:20.04
docker run -i -t -d ubuntu:20.04

If you want to pull or store an image in your operating system, then run this first command, it will store Ubuntu Image in your system.

Now there are three options with the run command:-

-i — To make the OS Interactive.

-t — To Give it a terminal for writing commands.

-d — To Run the Operating System in the background.

From an Image, you can launch the Operating system and in the docker world, this O.S is called Container.

Dokcer ps :- Tell how many current os running inside docker. (-a) will tell all the stopped & running containers.
free -m :- Current consumption of RAM from base system.
watch -n 1 free -m :- Watching every second the resource usage.

Docker run -it --name=cont1 centos:8 --> If you want to set a name of your O.S
Docker stop cont1 :- To Stop a specific container.

On top of Red Hat, We Install Docker & on top of Docker we launch multiple O.S.

Want to know the location of any command, where this command is located, and what script is written behind this command?

Then Run:- Which cmd ( eg. which date → /usr/bin/date )
Data Inside the Container is Permanent.

Whenever you write a run command, it launches a new os every time.
docker rm <img id> Will delete that image permanently

To Start Specified or Previous O.S:- docker start <img id>.
docker rmi centos:latest:-
To remove docker image

Container → Running Operating System.
Image → Bootable Image through which you launch OS.

docker container rm -f $(docker container ls -a -q)
Very Sensitive Command

rm -f means remove forcefully, ls = list, -a = all, -q = query,
all in $ means this single command will list all the containers
and all will be deleted forcefully.

Ok, let me explain it simply

rm -f = remove forcefully
ls -a -q = list all query
$() = all docker containers

In Linux, $ means taking arguments, and inside this,
there will be a list of containers, which means docker container
cmd will remove all these forcefully one by one.

left ctrl + p + q → To exit without stopping container.