Sunday, March 22, 2020

12. DOCKER & KUBERNETES : KUBERNETES ARCHITECTURE

12. DOCKER & KUBERNETES : KUBERNETES ARCHITECTURE


https://drive.google.com/file/d/1fd2gYPFaOfKU48u_XB3OMP99yZIkrc2N/view?usp=sharing





#######################################################################
KUBERNATES
#######################################################################

############################Every day activity on Kubernates#####################
//in normal cmd - COMMAND1
----------
C:\Program Files\Kubernetes\Minikube\minikube start

//verify
minikube status

kubectl cluster-info
//you will see : Kubernetes master is running at https://192.168.99.101:8443
//All master service will run even in each Node also
//we see minikube server



//another cmd - COMMAND2
--------
minikube dashboard
//you will see browser opening - http://127.0.0.1:52935/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/overview?namespace=default

############################Every day activity on Kubernates#####################

//In 1st Terminal (minicube terminal)
//How many nodes are there
kubectl get nodes
//NAME       STATUS   ROLES    AGE    VERSION
//minikube   Ready    master   169m   v1.17.0
//it has master act as dual (both master and node)
kubectl get namespaces
//NAME                   STATUS   AGE
//default                Active   171m
//kube-node-lease        Active   171m
//kube-public            Active   171m
//kube-system            Active   171m
//kubernetes-dashboard   Active   170m

kubectl describe node minikube   
//same as inspect in docker, and inspect can work on any object
//but here we have to mention which object (eg: node)
//tells how many CPU's : 2
//momory ~2GB
//pods 110 //this is quota
//OS Image : Buildroot 2019.02.7
//OS : Linux
//Container Runtime : docker://19.3.5

kubectl describe namespaces kube-system
//No resource quota
//No LimitRange resources


//to check all the objects available
//In GIT bash terminal
kubectl api-resources
//nodes no
//namespaces ns
//pods po
//bindings
//services svc
//deployments ds

kubectl api-resources | grep pod  //will not work

//normal terminal
//what are all pods in kube-system
//here we can see all pods(services) available for kube-system, which mentioned in image Master
kubectl get po -n kube-system  //kube-sysem : its namespace
//kubectl get po - No resources found in default namespace so we have to give name space as above
//NAME                               READY   STATUS    RESTARTS   AGE
//coredns-6955765f44-4tnjq           1/1     Running   0          3h8m
//coredns-6955765f44-jbnn8           1/1     Running   0          3h8m
//etcd-minikube                      1/1     Running   0          3h8m
//kube-addon-manager-minikube        1/1     Running   0          3h8m
//kube-apiserver-minikube            1/1     Running   0          3h8m
//kube-controller-manager-minikube   1/1     Running   0          3h8m
//kube-proxy-pthhz                   1/1     Running   0          3h8m
//kube-scheduler-minikube            1/1     Running   0          3h8m
//storage-provisioner                1/1     Running   0          3h8m

kubectl get deployment -n kube-system
//NAME      READY   UP-TO-DATE   AVAILABLE   AGE
//coredns   2/2     2            2           3h10m

kubectl get po -n kube-system -o wide

kubectl describe pod etcd-minikube 

//normal termial
minikube ssh
sudo -i
ls /var
ls /var/lib
ls /var/lib/minikube
ls /var/lib/minikube/etcd
ls -a /var/lib/minikube/etcd/member

//where is docker running
ps ax | grep dockerd
//2545 ?        Ssl    5:48 /usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --default-ulimit=nofile=1048576:1048576 --tlsverify --tlscacert /etc/docker/ca.pem
//all docker command will work here
//kubectl will not work here


//in kubectl terminal
kubectl get deploy -n kube-system

//---------list pods belonging to particular deployment---------------------
//kubectl get po -n kube-system will list down all the pods but we have to filter
//1st get the selector:filter
kubectl get deployments -n kube-system -o wide
//we will get : selector as "k8s-app=kube-dns"

//2nd give selector
kubectl get po -n kube-system -l k8s-app=kube-dns  //give above selector - k8s-app=kube-dns

---------------------------------------------------------------
//create namespace
kubectl create ns demo
//namespace/demo created

kubectl describe ns demo
//No resource quota
//No LimitRange resource

//going to deploy in to namespace
//1st create deployment
//creating deployment "nginx-deployment" in namespace = "demo" with pod contains continers of "nginx" with replicaiton of 2
//it will create 2 POD as replica is 2
//pod contains container of "nginx"
kubectl run nginx-deployment --image=nginx --port=80 --replicas=2 -n demo 

kubectl get pods -n demo
//we see 2 pods

//go inside the pod
kubectl exec -i -t nginx-deployment-5567b746cd-dt28v bash -n demo

exit

//verify pods are running or not
kubectl get pods -n demo

//increase the replica from 2 to 4 ----------------------
//1st check how many replica we have
kubectl get deployments -n demo
//2/2

//we use edit
kubectl edit deployment nginx-deployment -n demo
//opens a YAML file
//under spec: replicas:2  //modify from 2 to 4

kubectl get deployments -n demo
//now we see 4/4
//nginx-deployment   4/4     4            4           11m

kubectl get pods -n demo
//we will see 4 Pods bez replica is 4

//decrease the replica to 2
//instead of edit, use scale : another way to change replica
kubectl scale deployment nginx-deployment --replicas=2 -n demo

kubectl get pods -n demo
////we will see 2 pods again

kubectl delete pod nginx-deployment-5567b746cd-8bnmx -n demo
//deleted

kubectl get pods -n demo
////we will see 2 pods again bez deployment maintains replica 2 always

//to check what events done on this namespace
kubectl get events -n demo
//88s         Normal   Pulling            pod/nginx-deployment-5567b746cd-79cbc    Pulling image "nginx"
//83s         Normal   Pulled             pod/nginx-deployment-5567b746cd-79cbc    Successfully pulled image "nginx"
//83s         Normal   Created            pod/nginx-deployment-5567b746cd-79cbc    Created container nginx-deployment

LOGS#########################
1. Service logs
2. POD logs
3. Namespace logs


kubectl get pods -n demo

kubectl describe pod  nginx-deployment-5567b746cd-79cbc -n demo

//how to check whether service running in pod or not
//we have 2 pods
kubectl describe pod  nginx-deployment-5567b746cd-79cbc -n demo
//Port: 80/TCP
//Host Port: 0/TCP
//means service is not running

//Create Extenrnal service-###############################################
//Expose the deployment outside the cluster (means : public servvice)
//going to expose all deployments
kubectl get deployments -n demo  //check how many deployments we have

//expose
kubectl expose deployment nginx-deployment --type=NodePort -n demo
//service/nginx-deployment exposed

kubectl get services -n demo
//NAME               TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
//nginx-deployment   NodePort   10.96.149.146   <none>        80:31032/TCP   16s

kubectl describe svc nginx-deployment -n demo
//Endpoints:                172.17.0.10:80,172.17.0.6:80
//bez we have 2 pods we get 2 ips

minikube ip
//192.168.99.101

minikube service nginx-deployment -n demo
//it will open the browser with ip and port
//192.168.99.101


//Create Internal service-###############################################
kubectl run nginx-internal --image=nginx --port=80 -n demo
//deployment.apps/nginx-internal created

kubectl get deployments -n demo

kubectl expose deployment nginx-internal --type=ClusterIP -n demo

kubectl get services -n demo
//nginx-internal     ClusterIP   10.96.149.15

minikube service nginx-internal -n demo   //since service is exposed as internal 
NAMESPACE |      NAME      | TARGET PORT |     URL      |
|-----------|----------------|-------------|--------------|
| demo      | nginx-internal |             | No node port


//since service is exposed as internal we cannot open in browser
//another termial ssh machine (minikube ssh)
curl 10.96.149.15:80
//we see index.html


//Expose service as External IP (LoadBalancer) ###############################################
//For this we should have Cloud
//Showing in Google Cloud
kubectl run nginx-external --image=nginx --port=80

kubectl get deployments

kubectl expose deployment nginx-external --type=LoadBalancer

kubectl get services
//wait for service it will show ip

//open browser
http://35.188.191.136/


-----------------------------------------------------
//all services available
kubectl get services -n kube-system

//TCP -> gateway to POD
//UDP -> POD to POD communication...

minikube addons list
//metrics server

//we will enable metrics server (Monitoring tool)
minikube addons enable metrics-server
// metrics-server was successfully enabled

kubectl get pods -n kube-system
//we see metrics   running

//close minikube dashboard browser which was open
//come out from minikube dashboard (Ctrl + C)
//run again
minikube dashboard
//again browser will open with dashboard with graphs
//leftside navigation - Nodes
//click on minikube link below
//filter namespace "demo"
//we see pods , its memory etc...


//How to create a POD with out deployment############################
kubectl run --generator=run-pod/v1 --image=nginx nginx-pod --port=80
//POD is created without deployment, we did not get warning bez we used --generator
//it will create in default namespace

kubectl get pods

//delete pod
kubectl delete pod nginx-pod
//deleted

//to pass env variable in command
//in YAML we hardcoded password in docker file
//but in kubernates we can pass in command
kubectl get secrets

//describe with name given above command
kubectl describe secret default-token-q4ql9
//token:      eyJhbGciOiJSUzI1NiIsImtpZCI6Ik1HWGlrdnhUQjNPUC1kMDNJMVpYUEhlQ3BCYVY1ZWMwOTdfUVQ
//ca.crt:     1066 bytes
//namespace:  7 bytes

//we will create similar secret file with username and password
kubectl create secret generic db-pass-values --from-literal=username=root --from-literal=password=admin
//secret/db-pass-values created

kubectl get secrets
//we see new entry which we created - "db-pass-values"
//db-pass-values        Opaque                                2      42s
//default-token-q4ql9   kubernetes.io/service-account-token   3      6h44m

kubectl describe secret db-pass-values
//Name:         db-pass-values
//Namespace:    default
//Labels:       <none>
//Annotations:  <none>


//In real time only we can manage deployment, we cannot create, delete deployments

//get roles
kubectl get clusterroles -n kube-system
//NAME                                                                   AGE
//admin                                                                  6h46m
//cluster-admin

kubectl describe clusterroles admin -n kube-system



11. DOCKER & KUBERNETES : KUBERNETES INSTALLATION

11. DOCKER & KUBERNETES : KUBERNETES INSTALLATION

#######################################################################

KUBERNATES INSTALL

#######################################################################



------------------------ 1. kubectl ----------------------------------------------------------------------
google.com

search -> kubectl install

https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-windows

paste it in - C:\Windows\System32\kubectl.exe


-----------------------2. minikube (VirtualBox with Docker & Kubernates Installed--------------------------
google.com

search for - minikube install

https://github.com/kubernetes/minikube/releases

C:\Program Files\Kubernetes\minikube-installer.exe

//Doubbleclick and install


//Minicube is a Virtual machine with Docker and Kubernaties installed in it
//1st docker on top of that kubernates installed
//in Oracle VM VirtualBox - you see new entry as minikube






#######################################################################

KUBERNATES START

#######################################################################

//TERMINAL1 : in normal cmd
----------
C:\Program Files\Kubernetes\Minikube\minikube start --cpus=2 --memory=3072 --vm-driver=virtualbox
    //it will create virtualBox takes more time
    //Creating virtualbox VM (CPUs=2, Memory=3072MB, Disk=20000MB) ...







//TERMINAL2: another cmd
--------
minikube dashboard




//In Terminal1 verify the IP address
kubectl cluster-info







10. DOCKER & KUBERNETES : KUBERNETES INTRODUCTION

10. DOCKER & KUBERNETES : KUBERNETES INTRODUCTION


#######################################################################
KUBERNATES INTRODUCTION
#######################################################################

Why we need Kubernetes..? CLUSTER CONTAINER RUNTIME
-----------------------------------------

//In docker - If machine goes down then all services will go for toss
//In kubernates - multiple machines -
    //to get high availablility
    - if one m/c goes down other m/c will pick up

    Horizontal scale - Infra scale - m/c (VM based scaling, monolythic)
    Vertical scale - Service scale, if one container goes down then another container should pickup

POD = one or more container







9. DOCKER & KUBERNETES :

9. DOCKER & KUBERNETES :

8. DOCKER & KUBERNETES : OJET -> NodeJS -> MYSQL

8. DOCKER & KUBERNETES : OJET -> NodeJS -> MYSQL

Tuesday, March 17, 2020

7. DOCKER & KUBERNETES : Create Image of MYSQL DB and Create tables in it

7. DOCKER & KUBERNETES : Create Image of MYSQL DB and Create tables in it

Requirement: Create Image of MYSQL DB and create table and insert few records init. ##################
Step1: Keep ready one createdb.sql (creates the table and insert one row)
Step2: Create docker file and use createdb.sql init
Step3: Create Image using dockerfile
Step4: Run and test the Image
########################################################################
----------------------MYSQL in hub.docker.com---------------------------------------------
//Will use mysql image

docker pull mysql:5.7

docker images  //mysql is 456MB

docker inspect mysql:5.7  //ExposedPort 3306 port, CMD : mysqld,  volume : 

//In container we cannot modify in running container is
1. Docker image associated
2  ID - Readonly
3. Volume (data inside volume can change, but cannot add volume - Readonly, means during container creation if volume is assigned then later addition is not possible
4. Cannot increase decrease ports - Readonly

//What cannot change in Docker image
//Entire Docker image is readonly

//Overwrite and image is possible
//Overwrite a container is not possible (overright - ID, Volume, Porsts, DockerImage not possible)

//we will mount some thing to 
https://github.com/dhanan77/RESTAPI22.05/blob/master/createdb.sql

Step1: Keep ready one createdb.sql (creates the table and insert one row)
vi createdb.sql

//paste below code
####################################################
CREATE DATABASE IF NOT EXISTS `pythonlogin` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `pythonlogin`;

CREATE TABLE IF NOT EXISTS `accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `email` varchar(100) NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

INSERT INTO `accounts` (`id`, `username`, `password`, `email`) VALUES (1, 'test', 'test', 'test@test.com');

####################################################
Esc :wq!


ls

Step2: Create docker file and use createdb.sql init
vi Dockerfile2
####################################################
#mysql 5.7 Implementation of Custom DB created.
FROM mysql:5.7
label maintainer dj@dba-ops.com
ENV MYSQL_ROOT_PASSWORD=admin
COPY createdb.sql /docker-entrypoint-initdb.d/createdb.sql
####################################################
Esc :wq!

Step3: Create Image using dockerfile
//newmysql is image name
docker build -t newmysql -f Dockerfile2 .

vi .dockerignore 

      *.tar  //add this

Esc :wq!

ls -a  //should see .dockerignore

cat .dockerignore

Step4: Run and test the Image "newmysql" by creating the container "testdb"
docker run --name testdb -d newmysql  //it will give id

//check whether "testdb" container is running or not
docker ps -a | grep testdb

//verify db is ready to for connection , means sql file given is executed or not
docker logs testdb  //it will show port and othr information.. and we see in the log createdb.sql is executed..


6. DOCKER & KUBERNETES : ImageCreate Way2 : Create Image using Dockerfile

6. DOCKER & KUBERNETES : ImageCreate Way2 : Create Image using Dockerfile


Requirement: Creating Image using Dockerfile ############################################
Step1: Create docker file (vi Dockerfile)
Step2: Create Image using docker file (docker build -t newubuntu:1.0 -f Dockerfile .)
Step3: Run and test the image (docker run --rm newubuntu:1.0)
########################################################################################

Step1: Create docker file
Example1 : We will create DockerFile
##########################################
//refer image...

https://github.com/dhanan77/RESTAPI22.05

click on -> Sample.sh

#######################################
#!/bin/bash
if [ $# -gt 0 ]
then
if [ -f $1 ]
then
  echo "Contents of the file..."
  cat $1
else
  echo "File Not Found.."$1
fi
else
  echo "Not enough command line arguments..."
fi

########################################

copy

vi Sample.sh

paste

Esc :wq!

sh Sample.sh

sh Sample.sh xxxx

sh Sample.sh /etc/hosts

//create automation file (Docker file) for image management
vi Dockerfile

##############################################
# First Dockerfile simulation of Sample.sh
FROM ubuntu:16.04
LABEL MAINTAINER dj@devops.com
RUN mkdir /code
COPY Sample.sh /code/Sample.sh
RUN chmod +x /code/Sample.sh
CMD sh /code/Sample.sh /etc/hosts
#CMD ["sh","/code/Sample.sh","/etc/hosts"]
###############################################

Esc :wq!

ls  //we should have 2 files (Dockerfile   Sample.sh)

Step2: Create Image using docker file
//every thing does automatically mention all commands in Docker file and build..
//Every line in Dockerfile creates one layer.
//newubuntu is image name
//Creating image "newubuntu:1.0" using docker file "Dockerfile"
docker build -t newubuntu:1.0 -f Dockerfile .    //it will execute line by line mentioned in Dockerfile

docker history newubuntu:1.0  //to check all layers how layers are created...

docker inspect newubuntu:1.0

Step3: Run and test the image //we will test this image
docker run --rm newubuntu:1.0

//execute as bash, customers can go inside and check the code
//Means Its failing as Scaling section, bez people can go and paly with source code
//CF layer test - FAILED
docker run -i -t --rm newubuntu:1.0 bash
cd code
ls
cat Sample.sh

//customer can execute as below also
//CD layer test - FAILED
docker run --rm newubuntu:1.0 sh /code/Sample.sh xxx

docker run --rm newubuntu:1.0 xxx  //will not work

vi Dockerfile

###############################################
# First Dockerfile simulation of Sample.sh
FROM ubuntu:16.04
LABEL MAINTAINER dj@devops.com
RUN mkdir /code
COPY Sample.sh /code/Sample.sh
RUN chmod +x /code/Sample.sh
ENTRYPOINT ["sh","/code/Sample.sh"]
CMD ["/etc/hosts"]
CMD sh /code/Sample.sh /etc/hosts
#CMD ["sh","/code/Sample.sh","/etc/hosts"]
###############################################

Esc :wq!

//build again
docker build -t newubuntu:1.0 -f Dockerfile . 

//now test all security fails again
docker run -i -t --rm newubuntu:1.0 bash   //it will not go inside bash

docker run --rm newubuntu:1.0

docker run --rm newubuntu:1.0 /etc/resolv.conf  //valid file name should work

docker run --rm newubuntu:1.0 xxxxx  //invlid file name should not work

#########################################################################


Example2 : We will create DockerFile for PING and then create image##########################################


------------------- PING COMMAND in Docker file---------------------------------------------
//Do New operation ping like some part should be fixed and some parameter should come as parameter

ping 

docker pull ubuntu:trusty  //pull ping related layers

vi DockerfilePing

###############################################
# Second Dockerfile simulation of Ping
FROM ubuntu:trusty
LABEL MAINTAINER dj@netops.com
ENTRYPOINT ["ping","-c3"]
CMD ["localhost"]
###############################################

Esc :wq!

//build
//ping is image name
//Creating Image "ping:v1" using Dockerfile "DockerfilePing"
docker build -t ping:v1 -f DockerfilePing

docker history ping:v1 

docker run --rm ping:v1 //it will execute ping command mentioned DockerfilePing file

//go to Docker quickstart terminal

docker images

Different ways to ping:
1. Localhost (of Container IP)
2. Ping another Container IP
3. Ping Host IP (DM IP)
4. Ping External IP

//Testing on our newly created Image ping:v1
docker run --rm ping:v1
docker run --rm ping:v1 $(docker inspect -f "{{.NetworkSettings.IPAddress}}" TestLogs)
docker run --rm ping:v1 $(docker-machine ip default)
docker run --rm ping:v1 www.ndtv.com  //will work
docker run --rm ping:v1 www.hub.docker.com  //will not work as all cloud has security

4. DOCKER & KUBERNETES : ImageCreate Way1 : Create Image using Container -> Push Image to Cloud/OnPrem

4. DOCKER & KUBERNETES : ImageCreate Way1 : Create Image using Container  -> Push Image to Cloud/OnPrem


########################## How to create an image in Docker machine from Container  ###################################
Step1: 1st Create Container
Step2: Create Image from Container using "commit"


Step1: 1st Create Container -------------------------------------------------------------
//1st Create a normal container "TestUbuntu" from image "ubuntu"
docker create -i -t --name TestUbuntu --restart=always ubuntu  //if image is not there it will pull automatically

docker system df

docker start TestUbuntu  //start container

docker ps -a

docker attach TestUbuntu  //go to parent process of container

hostname //to get container ID

cat /etc/hosts  //to get container ID with IP address

vi  //not there in container

--------------------------------------------------
// inside container
//on top of container we are installing vi module
apt-get -y install vim

mkdir cloud

cd cloud

vi testfile

This is test file
Esc :wq!

cat testfile
------------------------------------------------------
//to check layers in image, 1st we have to exit from container
exit

docker inspect ubuntu  (make sure u r in docker@default, it will show how many layers ubuntu has... )

Step2: Create Image from Container using "commit" -------------------------------------------------------------
//want to create template
//covert container to image, because only image can share
//custom image of ubuntu and share with every one to use
//we are building custom image
//all the data inside container will be converted to image (only volume will not be there inside container other than this every thing comes)
//container (internally its directory) => convert to image (file) with layers

//creating image "revisedubuntu" from contianer "TestUbuntu"
docker commit -a "DJ Created this image @ `date`" TestUbuntu revisedubuntu

docker images  //you see custom image created

docker inspect revisedubuntu  //we see number of layers as N + 1  (N from base image. 1 is our custom logic(folder,vi, testfile) )

//how to share created image outside docker machine
//we will push image to hub.docker cloud
//1st we will test the image the we will push
//pull the image, crate, start, attach (Every thing is REST sync call.. and need to to one by one its difficult so use Run which does all together for us)
//Run we use only for testing purpose.

docker images

docker run --rm -i -t revisedubuntu  (after run remove bez we dont need after testing)
ps ax

//check all are there or not,means cloud directory, testfile etc
cd cloud
ls

docker ps -a  //we dont see new container running because we used Run, which we use just for testing purpose after test automatically it will remove

##########################################################################################


#############now testing is done, now we will share to other users means SHARE IN CLOUD ##########################
1. We will see how to share on hub.docker Cloud
2. We will see how to share in Oracle Cloud
3. We will see how to share in OnPrem (Using TAR)


1. We will see how to share on hub.docker Cloud
################## In hub.docker how to Push ######################
1. IDENTITY
---------------
docker login
  pavankumarmadhu123
  Pavan_123h

//verify username and password is registered 

docker info  //we see username updated

docker images

docker tag revisedubuntu pavankumarmadhu123/revisedubuntu:1

docker images  //we can see image id is same for original and reference what we created

docker push pavankumarmadhu123/revisedubuntu:1

//go and verify in https://hub.docker.com check if repository creted or not

//to remove image
docker images
docker rmi -f e66   //it will untag the image, then it will remove the image
//-f is force, 1st go to child and then parent

//Test the image use Run
docker run -i -t pavankumarmadhu123/revisedubuntu:1   //locally not available bez its deleted, so it will download from cloud

ls
cd cloud
ls
vi
exit
docker ps -a   //created with wiered name bez we did not give name while testing.

2. We will see how to share in Oracle Cloud
################## In OCI how to Push ######################
//In OCI how to use
OCI:
  - docker login phx.ocir.io   (docker login <<region name>>.ocir.io)
  - username Tenancyname
  - Password
MFA:
    - Fingerprint
    - AuthToken
    - SSH API
  - docker push 

3. We will see how to share in OnPrem (Using TAR)
#################### onPrem SHARE ####################
//Now we will share onPrem - means no Cloud

//To share object, Serialize DIS to TAR

//in Docker Terminal

cd ~

mkdir tars1703

cd tars1703

docker images  //it will be slower bez Hyperv comes in to picture

docker save -o backpu.tar pavankumarmadhu123/revisedubuntu:1   //serialize and save

ls -ltr

docker images

docker rmi -f e66

docker load < backpu.tar  //convert from TAR to image
############################################################

3. DOCKER & KUBERNETES : BASIC DETAILS

3. DOCKER & KUBERNETES : BASIC DETAILS


################ EVERY DAY ACTIVITY ##############################
double click on "Docker Quickstart Terminal"
wait for sometime to generate IP address...

putty
192.168.99.100
username: docker
password: tcuser

open another terminal
Create duplicate session

username: docker
password: tcuser
sudo -i

docker info  //to check how many images and containers are there
ps ax | grep dockerd

docker system df  //to check number of images and containers and size accupaid
docker ps -a //to check image and containers status (wether exited or running etc)
###########################################################

############### PRUNE #####################################

//its like inspect command works for all objects, [image, container, volume, network etc..]

//remove unwanted container
docker container prune  //like GC, it will remove all stopped containers
//this is same as docker rm <<containerName>> but prune does for us

docker system df

//remove unwanted image
docker image prune  //like GC, but it wont remage dongling images
docker image prune -a  //will remove all images which does not contain container in it

docker network prune

docker volume prune  

//prune for all objects together
docker system prune

##########################################################################



2. DOCKER & KUBERNETES : INSTALLATION

2. DOCKER & KUBERNETES : INSTALLATION

https://drive.google.com/file/d/1eq5ZGs9JH9F7R1z3wtUcKIWJi8HFr7MM/view?usp=sharing





Docker & Kubernaties
----------------------------
LINUX FUNDAMENTALS


https://hub.docker.com/
------------------------
search for docker images

oraclelinux
Its free
In Tag : check size and version

oracle database
Its enterprice product
Its not free : it will ask for payment

oracle weblogic Server
Its not free : it will ask for payment

httpd
its free : no check out process

docker
click on explore
click - DOCKER CE

click - DOCKER EE
AWS
Azure

EE and CE difference is same as open jdk and oracle jdk
Eg:
Application performance
memory leakage support

########################################

for oracle employees/customers

container-registry.oracle.com
Sign in


Docker is Architecture
Kubernaties is a framework
##################################################################

Step6:
https://github.com  
                username : pavankumarmadhu123
                password : Pavan_123g
Step7:
https://hub.docker.com/
                username : pavankumarmadhu123
                password : Pavan_123d

------------------------------------------------------------
As per the diagram we will install one by one now:

VM with Linux - TCL (Tiny Core Linux)
Docker Installed (Docker CLI)
Network of Host - NAT (Communicating externally)
VM - IP (DHCP) - HOA
SSH Keys (RSA) (Internal)
from VM should 

Step8: Already we have laptop with Windows10

Step9: Oracle VM VirtualBox

Step10: 
docs.docker.com
 -> Search for "Docker Toolbox"
OR https://github.com/docker/toolbox/releases
 -> download - DockerToolbox-19.03.1.exe
 -> Install

################ EVERY DAY ACTIVITY ##############################
double click on "Docker Quickstart Terminal"
wait for sometime to generate IP address...

putty
192.168.99.100
username: docker
password: tcuser

open another terminal
Create duplicate session

username: docker
password: tcuser
sudo -i
###########################################################

docker prompt
------
docker info




##############################################

Docker Architecture

SWARM
Docker Host
Docker machine

####################################
//Search Docker Image
Go to -> hub.docker.com -> search for -> oraclelinux
OR
//Through docker command
docker search oraclelinux  (to search)

//Create Docker Image (below we are creating total 3 images - oraclelinux, httpd, ubuntu)
docker pull oraclelinux
docker pull httpd  (it will pull latest)
//pull particular version
docker pull ubuntu:20.04

//Verify ALL Docker Images
docker images

//Inspect Docker Image
docker inspect oraclelinux 
OR
docker inspect 0f4  (Using Image Id)
docker history oraclelinux  (how this image is built)

docker inspect httpd  (Inspect this image)

docker images

docker system df

##################################
//Create container of httpd and verify what happens to container
//container name can be upper or lower
//image name should be lower case

docker create --name TestApache httpd

//container is a docker process so we should be able to see
docker ps -a

//start the container
docker start TestApache

docker ps -a

docker top TestApache

ps ax | grep containerd

docker inspect TestApache  (it has lot of secured data we should not share to every one)

docker ps -a

ls /dev | grep tty

//go inside container and see what we can see this is just to verify..
docker exec -i -t TestApache bash  (i - interactive, -t - default terminal)
ps   //will not work bez we are in child process
curl //will not work bez we are in child process
docker stop TestApache

docker ps -a  //u see it as Exited

docker top TestApache //since container is not running so there is no containerd available

docker start TestApache

docker top TestApache  //now you will see containerd, bez above we have started the container, but will give different Id

docker images

//now we will create container for Docker Image - "oraclelinux"

docker create --name TestOL oraclelinux  //it will run for milisec and exit immediately, bez we have not used -i, -t to run in foreground

docker start TestOL

docker ps -a | grep TestOL  //we see as status as Exited, because its not running in foreground

docker rm TestOL  //physical remove, means remove file itself
docker kill <<ContinerName>>     //immediate kill

docker create -i -t --name TestOL oraclelinux  //you will see created Id, to run in foreground (when we use shell then we can use this command)

docker ps -a | grep TestOL

docker top TestOL  //to see containerd Id

docker ps -a

//go inside a container and check the IP address created for that container.
//exec will always create child process
docker exec TestOL cat /etc/hosts     //its not bash command so no need of -i -t, means only if its a bash then use -i -t to go inside container

docker exec TestOL -i -t TestOL bash //it will create one more child process and entered in to child

exit  //exiting from child process

//go to parent process
docker attach TestOL
ps ax

exit  //exiting from parent process

docker ps -a

docker create -i -t --restart=always --name TestOL2 oraclelinux  //create with restart policy, so that when ever exit from parent it should restart automatically

docker start TestOL2

docker attach TestOL2

exit  //exit from parent

docker ps -a | gerp TestOL2  //it will be still running...


exit
docker-machine stop default