Monday, August 11, 2025

kubernetes part2

Kubernetes part2

Class 86th Kubernetes Part1 August 11th 

1.Self managed cluster  (everything managed by self master server,worker node ,data..etc)

  example of using tools 
    1.minikube (single node cluster) remain all them multi node cluster 
    2.kops
    3.kubeadm
    4.k3d

For Minikube setup below are the requirements
-->2CPUs  or more 
-->2GB of free memory 
-->20 GB of free disk space 
-->Internet connection
-->Container or virtual machine manager, such as: Docker 


Practical :
Step1: Create one Ec2 instance amazon linux , t3.small 2 VCPU,2 memory 20 GB lunched ,we will try mini 2 gb required.

https://minikube.sigs.k8s.io/docs/start/?arch=%2Fwindows%2Fx86-64%2Fstable%2F.exe+download

Step2:
[ec2-user@ip-10-0-2-53 ~]$ sudo -i
[root@ip-10-0-2-53 ~]# curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  126M  100  126M    0     0  96.7M      0  0:00:01  0:00:01 --:--:--  127M
rm: remove regular file 'minikube-linux-amd64'? yes
[root@ip-10-0-2-53 ~]# minikube version
minikube version: v1.36.0
commit: f8f52f5de11fc6ad8244afac475e1d0f96841df1-dirty

Step3: need to install docker 
[root@ip-10-0-2-53 ~]# yum install docker -y[root@ip-10-0-2-53 ~]# systemctl start docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; preset: disabled)
     Active: active (running) since Wed 2025-08-13 15:20:40 UTC; 19s ago
TriggeredBy: ● docker.socket
Step4: docker --force with out my permission it will start

[root@ip-10-0-2-53 ~]# minikube start --driver=docker --force * minikube v1.36.0 on Amazon 2023.8.20250808 (xen/amd64) ! minikube skips various validations when --force is supplied; this may lead to unexpected behavior * Using the docker driver based on user configuration
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A' * Done! kubectl is now configured to use "minikube" cluster and "default" namespace by
default
Step5: minikube status 
[root@ip-10-0-2-53 ~]# minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
Step6: git CLI tool git ,docker CLI docker only ,Kubernetes CLI kubectl (add/delete)
For Kubernete clusture to communicate, kubectl CLI tool will help 
Installation kubectl 
https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
[root@ip-10-0-2-53 ~]#    curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138  100   138    0     0   1197      0 --:--:-- --:--:-- --:--:--  1200
100 57.3M  100 57.3M    0     0   127M      0 --:--:-- --:--:-- --:--:--  127M
[root@ip-10-0-2-53 ~]#

Step7: We got one kubectl file ,for give execute permission to the file 
[root@ip-10-0-2-53 ~]# ls -lrt
total 58724
-rw-r--r--. 1 root root 60129464 Aug 13 19:34 kubectl

[root@ip-10-0-2-53 ~]# chmod -x kubectl
[root@ip-10-0-2-53 ~]# mv kubectl /usr/local/bin/
[root@ip-10-0-2-53 ~]# sudo chmod 777 /usr/local/bin/kubectl
[root@ip-10-0-2-53 ~]# kubectl version
Client Version: v1.33.3
Kustomize Version: v5.6.0
Server Version: v1.33.1

Pod (inside container, inside container application),pod is smallest portion 
Note:
Kubernetes will not deploy the containers directly on worker nodes.
Kubernetes has a object called POD which contains containers . Lets learn about PODS 


if you want see all the resource in Kubernetes give this command , these are Kubernetes object 
smallest object is in Kubernetes pod , one pod has one container or multiple container
We always work with pods only 

[root@ip-10-0-2-53 ~]# kubectl api-resources

Step1: list of pods to see the command 

[root@ip-10-0-2-53 ~]# kubectl get pods
No resources found in default namespace.

or 

[root@ip-10-0-2-53 ~]# kubectl get po
No resources found in default namespace.

if required you can put aliase in bash_profile 

Imperative Way :

Create the pod in imperative way ,below one 1 pod has 1 container is running
[root@ip-10-0-2-53 ~]# kubectl run pod-1 --image=nginx
pod/pod-1 created
[root@ip-10-0-2-53 ~]# kubectl get po
NAME    READY   STATUS    RESTARTS   AGE
pod-1   1/1     Running   0          17s

Step2: to get the pod ip ,we can know how many pod and node cluster ,here we used single node cluster 
[root@ip-10-0-2-53 ~]# kubectl get po -o wide
NAME    READY   STATUS    RESTARTS   AGE    IP           NODE       NOMINATED NODE   READINESS GATES
pod-1   1/1     Running   0          119s   10.244.0.3   minikube   <none>   
If you want see yaml format 
[root@ip-10-0-2-53 ~]# kubectl get po -o yaml
If you want see json format 
[root@ip-10-0-2-53 ~]# kubectl get po -o json
Step3: Creating some more pods 
[root@ip-10-0-2-53 ~]# kubectl run mypod --image=httpd
pod/mypod created
[root@ip-10-0-2-53 ~]# kubectl get po -o wide
NAME    READY   STATUS    RESTARTS   AGE     IP           NODE       NOMINATED NODE   READINESS GATES
mypod   1/1     Running   0          10s     10.244.0.4   minikube   <none>           <none>
pod-1   1/1     Running   0          7m39s   10.244.0.3   minikube   <none>           <none>
Declarative Way : manifest file 
Write file for pod creation apiVersion , V should be capital letter , here multiple thing
multiple version there  (deployment,pod,rba), we can that using the kubectl api-resources command
Step1: Metadata is information about data ,mycontainer container name ,nginx port 80

[root@ip-10-0-2-53 ~]# vi manifest.yaml [root@ip-10-0-2-53 ~]# cat manifest.yaml --- apiVersion: v1 kind: Pod metadata: name: newpod1 spec: containers: - name: mycontainer image: nginx ports: - containerPort: 80 [root@ip-10-0-2-53 ~]# kubectl create -f manifest.yaml pod/newpod1 created

Step4: new pod created
[root@ip-10-0-2-53 ~]# kubectl get po -o wide
NAME      READY   STATUS    RESTARTS   AGE   IP           NODE       NOMINATED NODE   READINESS GATES
mypod     1/1     Running   0          19m   10.244.0.4   minikube   <none>           <none>
newpod1   1/1     Running   0          64s   10.244.0.5   minikube   <none>           <none>
pod-1     1/1     Running   0          27m   10.244.0.3   minikube   <none>           <none>

Step5: if you want details of the pod give below command , you will get complete information about the detail ,if any pod not working ,we have to check first this command only.
[root@ip-10-0-2-53 ~]# kubectl describe pod newpod1
Name:             newpod1
Namespace:        default
Priority:         0
Service Account:  default
Node:             minikube/192.168.49.2
Start Time:       Wed, 13 Aug 2025 20:23:23 +0000
Labels:           <none>
Annotations:      <none>
Status:           Running
IP:               10.244.0.5
IPs:
  IP:  10.244.0.5
Containers:
  mycontainer:
    Container ID:   docker://299b8337f2320bcfa6abc75abf077fda16e1c192b26c2db69a43c6071375456a
    Image:          nginx
    Image ID:       docker-pullable://nginx@sha256:3ab4ed065a1437cbbd45e65617b1285bdf6523c6bf56a121e00df41720e09a89
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Wed, 13 Aug 2025 20:23:25 +0000
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-pgtgr (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True
  Initialized                 True
  Ready                       True
  ContainersReady             True
  PodScheduled                True
Volumes:
  kube-api-access-pgtgr:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    Optional:                false
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age    From               Message
  ----    ------     ----   ----               -------
  Normal  Scheduled  3m     default-scheduler  Successfully assigned default/newpod1 to minikube
  Normal  Pulling    2m59s  kubelet            Pulling image "nginx"
  Normal  Pulled     2m58s  kubelet            Successfully pulled image "nginx" in 1.036s (1.036s including waiting). Image size: 192237226 bytes.
  Normal  Created    2m58s  kubelet            Created container: mycontainer
  Normal  Started    2m58s  kubelet            Started container mycontainer

See above all event we can see 
Step6:  delete the pod using below command 
[root@ip-10-0-2-53 ~]# kubectl delete pod mypod
pod "mypod" deleted

[root@ip-10-0-2-53 ~]# kubectl get po
NAME      READY   STATUS    RESTARTS   AGE
newpod1   1/1     Running   0          7m57s
pod-1     1/1     Running   0          33m

To delete all pods 
[root@ip-10-0-2-53 ~]# kubectl delete pod --all
pod "newpod1" deleted
pod "pod-1" deleted
[root@ip-10-0-2-53 ~]# kubectl get po
No resources found in default namespace.

Label :

Step1:

Pod Labelling 
Whenever we create the pod ,we should expose the pod  so the application in the pod container able access internet or out side
For expose the pod ,we use services

[root@ip-10-0-2-53 ~]# vi manifest.yaml
[root@ip-10-0-2-53 ~]# cat manifest.yaml
---
apiVersion: v1
kind: Pod
metadata:
  name: newpod1
  labels:
   app: swiggy
spec:
 containers:
  - name: container-1
    image: nginx
    ports:
      - containerPort: 80

[root@ip-10-0-2-53 ~]# kubectl create -f manifest.yaml
pod/newpod1 created

Pod created succesfully

[root@ip-10-0-2-53 ~]# kubectl get po
NAME      READY   STATUS    RESTARTS   AGE
newpod1   1/1     Running   0          30s


Step2: We can create one po and container
[root@ip-10-0-2-53 ~]# vi manifest.yaml
[root@ip-10-0-2-53 ~]# cat  manifest.yaml
---
apiVersion: v1
kind: Pod
metadata:
  name: newpod2
  labels:
   app: uber
spec:
 containers:
  - name: container-1
    image: nginx
    ports:
      - containerPort: 80

[root@ip-10-0-2-53 ~]# kubectl create -f manifest.yaml
pod/newpod2 created


[root@ip-10-0-2-53 ~]# vi manifest.yaml
[root@ip-10-0-2-53 ~]# cat  manifest.yaml
---
apiVersion: v1
kind: Pod
metadata:
  name: newpod3
  labels:
   app: zomato
spec:
 containers:
  - name: container-1
    image: nginx
    ports:
      - containerPort: 80

[root@ip-10-0-2-53 ~]# kubectl create -f manifest.yaml
pod/newpod3 created

[root@ip-10-0-2-53 ~]# cat manifest.yaml
---
apiVersion: v1
kind: Pod
metadata:
  name: newpod4
  labels:
   app: uber
spec:
 containers:
  - name: container-1
    image: nginx
    ports:
      - containerPort: 80

[root@ip-10-0-2-53 ~]# kubectl create -f manifest.yaml
pod/newpod4 created

[root@ip-10-0-2-53 ~]# kubectl get po --show-labels
NAME      READY   STATUS    RESTARTS   AGE     LABELS
newpod1   1/1     Running   0          8m7s    app=swiggy
newpod2   1/1     Running   0          5m      app=uber
newpod3   1/1     Running   0          3m21s   app=zomato
newpod4   1/1     Running   0          95s     app=uber


Step3: if you want get only uber label pods using below command 
[root@ip-10-0-2-53 ~]# kubectl get po -l app=uber
NAME      READY   STATUS    RESTARTS   AGE
newpod2   1/1     Running   0          6m28s
newpod4   1/1     Running   0          3m3s
[root@ip-10-0-2-53 ~]# kubectl get po -l app=zomato
NAME      READY   STATUS    RESTARTS   AGE
newpod3   1/1     Running   0          4m59s

Single base select is called equality based selector  

Step4: multiple label to select 
[root@ip-10-0-2-53 ~]# kubectl get po -l 'app in(zomato,uber)'
NAME      READY   STATUS    RESTARTS   AGE
newpod2   1/1     Running   0          10m
newpod3   1/1     Running   0          9m17s
newpod4   1/1     Running   0          7m31s

We can called set based sector 

Step5: i have create one po newpod5 lable not exist ,we can attache the label 

[root@ip-10-0-2-53 ~]# kubectl run newpod5 --image=nginx
pod/newpod5 created
[root@ip-10-0-2-53 ~]# kubectl get po --show-labels
NAME      READY   STATUS    RESTARTS   AGE   LABELS
newpod1   1/1     Running   0          17m   app=swiggy
newpod2   1/1     Running   0          14m   app=uber
newpod3   1/1     Running   0          12m   app=zomato
newpod4   1/1     Running   0          10m   app=uber
newpod5   1/1     Running   0          7s    run=newpod5

Step6:
[root@ip-10-0-2-53 ~]# kubectl label pod newpod5 app=swiggy
pod/newpod5 labeled
[root@ip-10-0-2-53 ~]# kubectl get po --show-labels
NAME      READY   STATUS    RESTARTS   AGE     LABELS
newpod1   1/1     Running   0          19m     app=swiggy
newpod2   1/1     Running   0          16m     app=uber
newpod3   1/1     Running   0          14m     app=zomato
newpod4   1/1     Running   0          13m     app=uber
newpod5   1/1     Running   0          2m21s   app=swiggy,run=newpod5

[root@ip-10-0-2-53 ~]# kubectl label pod newpod2 env=dev
pod/newpod2 labeled
[root@ip-10-0-2-53 ~]# kubectl get po --show-labels
NAME      READY   STATUS    RESTARTS   AGE     LABELS
newpod1   1/1     Running   0          21m     app=swiggy
newpod2   1/1     Running   0          18m     app=uber,env=dev
newpod3   1/1     Running   0          16m     app=zomato
newpod4   1/1     Running   0          14m     app=uber
newpod5   1/1     Running   0          3m51s   app=swiggy,run=newpod5

[root@ip-10-0-2-53 ~]# kubectl get po -l app=swiggy
NAME      READY   STATUS    RESTARTS   AGE
newpod1   1/1     Running   0          22m
newpod5   1/1     Running   0          5m10s

[root@ip-10-0-2-53 ~]# kubectl get po -l app!=swiggy
NAME      READY   STATUS    RESTARTS   AGE
newpod2   1/1     Running   0          19m
newpod3   1/1     Running   0          17m
newpod4   1/1     Running   0          16m


Node selector -->we need inform prior, which worker node pod going to be created
Worker node we have make it label , and  master node will decided based on label create the pod 


Reference Document:

https://mustafa-k8s.hashnode.dev/essential-kubernetes-pod-concepts-for-beginners-to-master

https://mustafa-k8s.hashnode.dev/labels-selectors-and-node-selectors

--Thanks

Friday, August 8, 2025

Kubernetes part1

Kubernetes part1

Class 85th kubernetes Part1 August 8th 

Simple to tell advanced version of docker is called kubernetes

Intro:Kubernetes short form k8s,Docker logs show Container, Kubernetes logs shows Ship wheel

Docker containers maintained by kubernetes ,Docker is containerization tool ,kubernetes orchestration tool

What case we are using docker or Kubernetes?
if any budget,low members are using docker swarm,performance modernate (no autscaling,no rollback, there is a downtime )
if budget is good, high members are used prefer Kubernetes performance high , all drawback overcome with kubernetes 

We have use docker upto create image , containers are create by k8s
how we create container in docker , in k8s we create pods
K8s Architecture:
Cluster two types of node 1.control plain (master node),2.worker node
1.Master node has 4 components ,API Server, Controller manager ,scheduler, etcd
User /Operator inform to create pod API server take the request it will go scheduler 
pod will create worker nodes ,scheduler will decide which worker node to create pod 

For ex:- Worker node1 has 3 pods ,Worker node2 has 2 pods ,so automatically scheduler decide create pod in workernode2.
based on parameter size (2cpus,4gb ram), it will choose wokernode

After decide by the scheduler inform back API server ,where to create pod , API Server info to Kubelet ,Kubelet get the image from docker ,if image exist then create the pod ,pod has container,
container has running application. after create pod send the response back kubelet to api server ,
after that api server update the data in etcd ,etcd  has complete information about pods and how many worker just like database for entire cluster , the data will store in key value format

Control manager: we have there types of control manager  ,whenever pod is deleted 
automatically it will create container
1.Node controller ,
2.Replication controller,
3.Service controller 

    

 


Kube-proxy: it will maintain the network configuration , one worker node to another worker node communicate establish the network connection.

To implement kubernetes we need create clusters 
1.Self managed cluster  (everything managed by self master server,worker node ,data..etc)
    example of using tools 
    1.minikube (single node cluster) remain all them muli mode cluster 
    2.kops
    3.kubeadm
    4.k3d
using these tool ,we can able create our own cluster 
2.Cloud managed cluster (For master node everything managed by cloud provider, we have maintainer only worker node here)
   example of using tools 
  1. AWS :EKS 
  2.Azure :AKS
  3.CGP : GKS

Single node :only one server maintained both master and worker node in the same server 
Multi node: master node separate server and work node separate server.

In realtime mulinode is using , for testing purpose we use Single node 
  
Reference document: https://mustafa-k8s.hashnode.dev/well-explained-kubernetes-architecture

--Thanks 


 





Wednesday, August 6, 2025

Docker Part5

Docker Part5

Class 83rd DOCKER Part5 August 6th 

Docker volume: Container to container data replication purpose using the docker volume

In docker we are running our application in containers and database container, if any network issues happen container will loss, docker manage create new container , but database container data will loss, too over come the issue we are using Docker volume

Forex:- application container -->database container 

At the time of Container creation it self we have create docker volume mouth the containers 

so that docker volume communicate the container1 and container2,synchroize the data ,we can protect one container Read only mode .

Data volume are independent container attached to that , if all containers removed, docker volume persist, we can attach new container to that 

Practical 

Step1: Create one EC2 instance Amazon Linux .

[root@ip-10-0-2-55 ~]# yum install docker -y && systemctl start docker

[root@ip-10-0-2-55 ~]# docker --version

Docker version 25.0.8, build 0bab007

Step2: Create container, here -v means volume given name of the volume1, mount the volume data in /tmp directory  

[root@ip-10-0-2-55 ~]# docker run -itd --name container1 -v volume1:/tmp ubuntu
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
32f112e3802c: Pull complete
Digest: sha256:a08e551cb33850e4740772b38217fc1796a66da2506d312abe51acda354ff061
Status: Downloaded newer image for ubuntu:latest
d250b2cd9d279417ef82e8cee6a623392a776b51318c9817527953f6d665a42e

--For this command to see list of containers
[root@ip-10-0-2-55 ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED              STATUS              PORTS     NAMES
d250b2cd9d27   ubuntu    "/bin/bash"   About a minute ago   Up About a minute             container1
--For this command to see list of volumes
[root@ip-10-0-2-55 ~]# docker volume ls
DRIVER    VOLUME NAME
local     volume1

Step3: As see above we have container mounted /tmp folder,

--Goto inside the container, Create some files in /tmp directory
[root@ip-10-0-2-55 ~]# docker exec -it container1 bash
root@d250b2cd9d27:/#

root@d250b2cd9d27:/# cd /tmp
root@d250b2cd9d27:/tmp# touch jenkins.txt Dockerfile one.yaml
root@d250b2cd9d27:/tmp# ls -lrt
total 0
-rw-r--r--. 1 root root 0 Aug 12 17:17 one.yaml
-rw-r--r--. 1 root root 0 Aug 12 17:17 jenkins.txt
-rw-r--r--. 1 root root 0 Aug 12 17:17 Dockerfile

--Click contrl+D exit from the container 
[root@ip-10-0-2-55 ~]# yum docker insatll -y
No such command: docker. Please use /usr/bin/yum --help
It could be a YUM plugin command, try: "yum install 'dnf-command(docker)'"
[root@ip-10-0-2-55 ~]# yum insatll docker -y
No such command: insatll. Please use /usr/bin/yum --help
It could be a YUM plugin command, try: "yum install 'dnf-command(insatll)'"
[root@ip-10-0-2-55 ~]# yum install docker -y && systemctl start docker
Amazon Linux 2023 Kernel Livepatch repository                                                                       172 kB/s |  19 kB     00:00
Dependencies resolved.
====================================================================================================================================================
 Package                                   Architecture              Version                                   Repository                      Size
====================================================================================================================================================
Installing:
 docker                                    x86_64                    25.0.8-1.amzn2023.0.5                     amazonlinux                     46 M
Installing dependencies:
 container-selinux                         noarch                    3:2.233.0-1.amzn2023                      amazonlinux                     55 k
 containerd                                x86_64                    2.0.5-1.amzn2023.0.2                      amazonlinux                     26 M
 iptables-libs                             x86_64                    1.8.8-3.amzn2023.0.2                      amazonlinux                    401 k
 iptables-nft                              x86_64                    1.8.8-3.amzn2023.0.2                      amazonlinux                    183 k
 libcgroup                                 x86_64                    3.0-1.amzn2023.0.1                        amazonlinux                     75 k
 libnetfilter_conntrack                    x86_64                    1.0.8-2.amzn2023.0.2                      amazonlinux                     58 k
 libnfnetlink                              x86_64                    1.0.1-19.amzn2023.0.2                     amazonlinux                     30 k
 libnftnl                                  x86_64                    1.2.2-2.amzn2023.0.2                      amazonlinux                     84 k
 pigz                                      x86_64                    2.5-1.amzn2023.0.3                        amazonlinux                     83 k
 runc                                      x86_64                    1.2.6-1.amzn2023.0.1                      amazonlinux                    3.7 M

Transaction Summary
====================================================================================================================================================
Install  11 Packages

Total download size: 77 M
Installed size: 292 M
Downloading Packages:
(1/11): container-selinux-2.233.0-1.amzn2023.noarch.rpm                                                             1.4 MB/s |  55 kB     00:00
(2/11): iptables-libs-1.8.8-3.amzn2023.0.2.x86_64.rpm                                                               8.3 MB/s | 401 kB     00:00
(3/11): iptables-nft-1.8.8-3.amzn2023.0.2.x86_64.rpm                                                                4.5 MB/s | 183 kB     00:00
(4/11): libcgroup-3.0-1.amzn2023.0.1.x86_64.rpm                                                                     1.5 MB/s |  75 kB     00:00
(5/11): libnetfilter_conntrack-1.0.8-2.amzn2023.0.2.x86_64.rpm                                                      2.1 MB/s |  58 kB     00:00
(6/11): libnfnetlink-1.0.1-19.amzn2023.0.2.x86_64.rpm                                                               1.1 MB/s |  30 kB     00:00
(7/11): libnftnl-1.2.2-2.amzn2023.0.2.x86_64.rpm                                                                    3.0 MB/s |  84 kB     00:00
(8/11): pigz-2.5-1.amzn2023.0.3.x86_64.rpm                                                                          2.7 MB/s |  83 kB     00:00
(9/11): containerd-2.0.5-1.amzn2023.0.2.x86_64.rpm                                                                   48 MB/s |  26 MB     00:00
(10/11): runc-1.2.6-1.amzn2023.0.1.x86_64.rpm                                                                        13 MB/s | 3.7 MB     00:00
(11/11): docker-25.0.8-1.amzn2023.0.5.x86_64.rpm                                                                     46 MB/s |  46 MB     00:00
----------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                76 MB/s |  77 MB     00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                            1/1
  Installing       : runc-1.2.6-1.amzn2023.0.1.x86_64                                                                                          1/11
  Installing       : containerd-2.0.5-1.amzn2023.0.2.x86_64                                                                                    2/11
  Running scriptlet: containerd-2.0.5-1.amzn2023.0.2.x86_64                                                                                    2/11
  Installing       : pigz-2.5-1.amzn2023.0.3.x86_64                                                                                            3/11
  Installing       : libnftnl-1.2.2-2.amzn2023.0.2.x86_64                                                                                      4/11
  Installing       : libnfnetlink-1.0.1-19.amzn2023.0.2.x86_64                                                                                 5/11
  Installing       : libnetfilter_conntrack-1.0.8-2.amzn2023.0.2.x86_64                                                                        6/11
  Installing       : iptables-libs-1.8.8-3.amzn2023.0.2.x86_64                                                                                 7/11
  Installing       : iptables-nft-1.8.8-3.amzn2023.0.2.x86_64                                                                                  8/11
  Running scriptlet: iptables-nft-1.8.8-3.amzn2023.0.2.x86_64                                                                                  8/11
  Installing       : libcgroup-3.0-1.amzn2023.0.1.x86_64                                                                                       9/11
  Running scriptlet: container-selinux-3:2.233.0-1.amzn2023.noarch                                                                            10/11
  Installing       : container-selinux-3:2.233.0-1.amzn2023.noarch                                                                            10/11
  Running scriptlet: container-selinux-3:2.233.0-1.amzn2023.noarch                                                                            10/11
  Running scriptlet: docker-25.0.8-1.amzn2023.0.5.x86_64                                                                                      11/11
  Installing       : docker-25.0.8-1.amzn2023.0.5.x86_64                                                                                      11/11
  Running scriptlet: docker-25.0.8-1.amzn2023.0.5.x86_64                                                                                      11/11
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /usr/lib/systemd/system/docker.socket.

  Running scriptlet: container-selinux-3:2.233.0-1.amzn2023.noarch                                                                            11/11
  Running scriptlet: docker-25.0.8-1.amzn2023.0.5.x86_64                                                                                      11/11
  Verifying        : container-selinux-3:2.233.0-1.amzn2023.noarch                                                                             1/11
  Verifying        : containerd-2.0.5-1.amzn2023.0.2.x86_64                                                                                    2/11
  Verifying        : docker-25.0.8-1.amzn2023.0.5.x86_64                                                                                       3/11
  Verifying        : iptables-libs-1.8.8-3.amzn2023.0.2.x86_64                                                                                 4/11
  Verifying        : iptables-nft-1.8.8-3.amzn2023.0.2.x86_64                                                                                  5/11
  Verifying        : libcgroup-3.0-1.amzn2023.0.1.x86_64                                                                                       6/11
  Verifying        : libnetfilter_conntrack-1.0.8-2.amzn2023.0.2.x86_64                                                                        7/11
  Verifying        : libnfnetlink-1.0.1-19.amzn2023.0.2.x86_64                                                                                 8/11
  Verifying        : libnftnl-1.2.2-2.amzn2023.0.2.x86_64                                                                                      9/11
  Verifying        : pigz-2.5-1.amzn2023.0.3.x86_64                                                                                           10/11
  Verifying        : runc-1.2.6-1.amzn2023.0.1.x86_64                                                                                         11/11

Installed:
  container-selinux-3:2.233.0-1.amzn2023.noarch           containerd-2.0.5-1.amzn2023.0.2.x86_64         docker-25.0.8-1.amzn2023.0.5.x86_64
  iptables-libs-1.8.8-3.amzn2023.0.2.x86_64               iptables-nft-1.8.8-3.amzn2023.0.2.x86_64       libcgroup-3.0-1.amzn2023.0.1.x86_64
  libnetfilter_conntrack-1.0.8-2.amzn2023.0.2.x86_64      libnfnetlink-1.0.1-19.amzn2023.0.2.x86_64      libnftnl-1.2.2-2.amzn2023.0.2.x86_64
  pigz-2.5-1.amzn2023.0.3.x86_64                          runc-1.2.6-1.amzn2023.0.1.x86_64

Complete!
[root@ip-10-0-2-55 ~]# systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; preset: disabled)
     Active: active (running) since Tue 2025-08-12 16:39:29 UTC; 3min 20s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 5036 ExecStartPre=/bin/mkdir -p /run/docker (code=exited, status=0/SUCCESS)
    Process: 5052 ExecStartPre=/usr/libexec/docker/docker-setup-runtimes.sh (code=exited, status=0/SUCCESS)
   Main PID: 5057 (dockerd)
      Tasks: 7
     Memory: 29.1M
        CPU: 330ms
     CGroup: /system.slice/docker.service
             └─5057 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --default-ulimit nofile=32768:65536

Aug 12 16:39:28 ip-10-0-2-55.eu-west-2.compute.internal systemd[1]: Starting docker.service - Docker Application Container Engine...
Aug 12 16:39:28 ip-10-0-2-55.eu-west-2.compute.internal dockerd[5057]: time="2025-08-12T16:39:28.592676147Z" level=info msg="Starting up"
Aug 12 16:39:28 ip-10-0-2-55.eu-west-2.compute.internal dockerd[5057]: time="2025-08-12T16:39:28.662669345Z" level=info msg="Loading containers: st>
Aug 12 16:39:29 ip-10-0-2-55.eu-west-2.compute.internal dockerd[5057]: time="2025-08-12T16:39:29.287917689Z" level=info msg="Loading containers: do>
Aug 12 16:39:29 ip-10-0-2-55.eu-west-2.compute.internal dockerd[5057]: time="2025-08-12T16:39:29.318821088Z" level=info msg="Docker daemon" commit=>
Aug 12 16:39:29 ip-10-0-2-55.eu-west-2.compute.internal dockerd[5057]: time="2025-08-12T16:39:29.318959956Z" level=info msg="Daemon has completed i>
Aug 12 16:39:29 ip-10-0-2-55.eu-west-2.compute.internal dockerd[5057]: time="2025-08-12T16:39:29.383068295Z" level=info msg="API listen on /run/doc>
Aug 12 16:39:29 ip-10-0-2-55.eu-west-2.compute.internal systemd[1]: Started docker.service - Docker Application Container Engine.
lines 1-22/22 (END)

Step4:
[root@ip-10-0-2-55 ~]# docker --version
Docker version 25.0.8, build 0bab007
[root@ip-10-0-2-55 ~]# docker run -itd --name container1 -v volume1:/tmp ubuntu
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
32f112e3802c: Pull complete
Digest: sha256:a08e551cb33850e4740772b38217fc1796a66da2506d312abe51acda354ff061
Status: Downloaded newer image for ubuntu:latest
d250b2cd9d279417ef82e8cee6a623392a776b51318c9817527953f6d665a42e
[root@ip-10-0-2-55 ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED              STATUS              PORTS     NAMES
d250b2cd9d27   ubuntu    "/bin/bash"   About a minute ago   Up About a minute             container1
[root@ip-10-0-2-55 ~]# docker volume ls
DRIVER    VOLUME NAME
local     volume1
[root@ip-10-0-2-55 ~]# docker exec -it container1 bash
root@d250b2cd9d27:/# touch jenkins.txt Dockerfile one.yaml
root@d250b2cd9d27:/# ls
Dockerfile  bin  boot  dev  etc  home  jenkins.txt  lib  lib64  media  mnt  one.yaml  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@d250b2cd9d27:/# rm jenkins.txt Dockerfile one.yaml
root@d250b2cd9d27:/# cd /tmp
root@d250b2cd9d27:/tmp# touch jenkins.txt Dockerfile one.yaml
root@d250b2cd9d27:/tmp# ls -lrt
total 0
-rw-r--r--. 1 root root 0 Aug 12 17:17 one.yaml
-rw-r--r--. 1 root root 0 Aug 12 17:17 jenkins.txt
-rw-r--r--. 1 root root 0 Aug 12 17:17 Dockerfile
root@d250b2cd9d27:/tmp# ^C
root@d250b2cd9d27:/tmp#
exit
[root@ip-10-0-2-55 ~]#

Step5:
[root@ip-10-0-2-55 ~]# docker volume inspect volume1
[
    {
        "CreatedAt": "2025-08-12T16:46:07Z",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/volume1/_data",
        "Name": "volume1",
        "Options": null,
        "Scope": "local"
    }
]

Step6: As see below ,which was you have created these file in container,the files are automatically replicated in docker volume.

[root@ip-10-0-2-55 _data]# pwd
/var/lib/docker/volumes/volume1/_data
[root@ip-10-0-2-55 _data]# ls -lrt
total 0
-rw-r--r--. 1 root root 0 Aug 12 17:17 one.yaml
-rw-r--r--. 1 root root 0 Aug 12 17:17 jenkins.txt
-rw-r--r--. 1 root root 0 Aug 12 17:17 Dockerfile

Step7: Created some more files in docker volume 

[root@ip-10-0-2-55 _data]# touch prabhu.txt naveen.txt sree.txt
[[root@ip-10-0-2-55 _data]# ls -lrt
total 0
-rw-r--r--. 1 root root 0 Aug 12 17:17 one.yaml
-rw-r--r--. 1 root root 0 Aug 12 17:17 jenkins.txt
-rw-r--r--. 1 root root 0 Aug 12 17:17 Dockerfile
-rw-r--r--. 1 root root 0 Aug 12 17:23 sree.txt
-rw-r--r--. 1 root root 0 Aug 12 17:23 prabhu.txt
-rw-r--r--. 1 root root 0 Aug 12 17:23 naveen.txt
[root@ip-10-0-2-55 _data]#

Step8: See automatically new files(prabhu,naveen,sree) coming to container1

[root@ip-10-0-2-55 _data]# docker exec -it container1 bash
root@d250b2cd9d27:/# cd /tmp
root@d250b2cd9d27:/tmp# ls -lrt
total 0
-rw-r--r--. 1 root root 0 Aug 12 17:17 one.yaml
-rw-r--r--. 1 root root 0 Aug 12 17:17 jenkins.txt
-rw-r--r--. 1 root root 0 Aug 12 17:17 Dockerfile
-rw-r--r--. 1 root root 0 Aug 12 17:23 sree.txt
-rw-r--r--. 1 root root 0 Aug 12 17:23 prabhu.txt
-rw-r--r--. 1 root root 0 Aug 12 17:23 naveen.txt

Step9: See Above Container1 amounted /tmp folder
                              volume1 /var/lib/docker/volumes/volume1/_data 
Both will synchronize, Now planning create Colntainer2 

[root@ip-10-0-2-55 _data]# docker run -itd --name container2 --mount src=volume1,destination=/opt ubuntu
2c55ceee626d0e51f9c7821e59811923e5428a0bdeb23c7302399cdd39b404cb


Step10: Go to inside the container 
[root@ip-10-0-2-55 _data]# docker exec -it container2 bash
root@2c55ceee626d:/#

See now automatically files created these coming from docker volume
root@2c55ceee626d:/# cd /opt
root@2c55ceee626d:/opt# ls
Dockerfile  jenkins.txt  naveen.txt  one.yaml  prabhu.txt  sree.txt

Step11: now planning create some file in container2 and need to check these file are coming to container1 or not 
Containter2  (vinay.txt srikanth.txt mustafa.txt) these file created 
root@2c55ceee626d:/opt# touch vinay.txt srikanth.txt mustafa.txt
root@2c55ceee626d:/opt# ls
Dockerfile  jenkins.txt  mustafa.txt  naveen.txt  one.yaml  prabhu.txt  sree.txt  srikanth.txt  vinay.txt

Ctrl+D exit form the container 

--As see below container1 automatically (vinay.txt srikanth.txt mustafa.txt)  these file are came from docker volume
[root@ip-10-0-2-55 _data]# docker exec -it container1 bash
root@d250b2cd9d27:/# cd /tmp
root@d250b2cd9d27:/tmp# ls
Dockerfile  jenkins.txt  mustafa.txt  naveen.txt  one.yaml  prabhu.txt  sree.txt  srikanth.txt  vinay.txt


Step12 : Even though ,Containers remove the docker volume should be present 

Delete containers 

[root@ip-10-0-2-55 _data]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED             STATUS             PORTS     NAMES
2c55ceee626d   ubuntu    "/bin/bash"   8 minutes ago       Up 8 minutes                 container2
d250b2cd9d27   ubuntu    "/bin/bash"   About an hour ago   Up About an hour             container1
[root@ip-10-0-2-55 _data]# docker rm -f container1 container2
container1
container2
[root@ip-10-0-2-55 _data]# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

See Volume should be present 

[root@ip-10-0-2-55 _data]# docker volume ls
DRIVER    VOLUME NAME
local     volume1

Step13: Docker volume present in this directory ,as you see 
volumes are stored in this directory
image are images stored in this directory 

[root@ip-10-0-2-55 docker]# pwd
/var/lib/docker
[root@ip-10-0-2-55 docker]# ls
buildkit  containers  engine-id  image  network  overlay2  plugins  runtimes  swarm  tmp  volumes

Step14: These volume1 our volume1 it has _data 
[root@ip-10-0-2-55 volume1]# pwd
/var/lib/docker/volumes/volume1
[root@ip-10-0-2-55 volume1]# ls -lrt
total 0
drwxrwxrwt. 2 root root 167 Aug 12 18:10 _data

Step15:as see our data exist in our volume ,even containers deleted 
[root@ip-10-0-2-55 _data]# pwd
/var/lib/docker/volumes/volume1/_data
[root@ip-10-0-2-55 _data]#  ls -lrt
total 0
-rw-r--r--. 1 root root 0 Aug 12 17:17 one.yaml
-rw-r--r--. 1 root root 0 Aug 12 17:17 jenkins.txt
-rw-r--r--. 1 root root 0 Aug 12 17:17 Dockerfile
-rw-r--r--. 1 root root 0 Aug 12 17:23 sree.txt
-rw-r--r--. 1 root root 0 Aug 12 17:23 prabhu.txt
-rw-r--r--. 1 root root 0 Aug 12 17:23 naveen.txt
-rw-r--r--. 1 root root 0 Aug 12 18:10 vinay.txt
-rw-r--r--. 1 root root 0 Aug 12 18:10 srikanth.txt
-rw-r--r--. 1 root root 0 Aug 12 18:10 mustafa.txt

Step16: Already existing containers ,we can not attach the our volume ,
only possible at time of container creation time we have create the volume or exiting volume amount the volume.

Create the Volume separately also
[root@ip-10-0-2-55 _data]# docker volume create myapp
myapp
[root@ip-10-0-2-55 _data]# docker volume ls
DRIVER    VOLUME NAME
local     myapp
local     volume1

Step17: Now planning to put the data to the volume 
[root@ip-10-0-2-55 _data]# cd /var/lib/docker/volumes/myapp/_data
[root@ip-10-0-2-55 _data]# pwd
/var/lib/docker/volumes/myapp/_data
[root@ip-10-0-2-55 _data]# ls

Step18: files created in volume 
[root@ip-10-0-2-55 _data]# touch app.java index.html styles.css
[root@ip-10-0-2-55 _data]# ls
app.java  index.html  styles.css

Step19: Now planning create container mount the volume

[root@ip-10-0-2-55 _data]# docker run -itd --name container3 --mount src=myapp,destination=/tmp ubuntu
fceb36fafe007bacad08130810a39d90302efae006b25ae0e2a23726c68fb654

Container3 is up ,go to inside check data exist or not 
[root@ip-10-0-2-55 _data]# docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS          PORTS     NAMES
fceb36fafe00   ubuntu    "/bin/bash"   29 seconds ago   Up 28 seconds             container3

Step20: File are came from docker volume to new container mounted /tmp folder

[root@ip-10-0-2-55 _data]# docker exec -it container3 bash
root@fceb36fafe00:/# cd /tmp
root@fceb36fafe00:/tmp# ls
app.java  index.html  styles.css


                              With out docker volume we can amount container host to container

Step1: Create one directory ,now these file mount to container 


[ec2-user@ip-10-0-2-55 ~]$ sudo -i
[root@ip-10-0-2-55 ~]# mkdir swiggy
[root@ip-10-0-2-55 ~]# cd swiggy
[root@ip-10-0-2-55 swiggy]# touch index.jsp app.py scripts.sh
[root@ip-10-0-2-55 swiggy]# pwd
/root/swiggy
[root@ip-10-0-2-55 swiggy]# ls
app.py  index.jsp  scripts.sh


Step2: See below we have created container4 ,if directory not exist it will create new directory 
pwd is present working directory copy the files to new directory

[root@ip-10-0-2-55 swiggy]# docker run -itd --name container4 -v $(pwd):/vakatisubbu/docker/  ubuntu
7d6cf0703787277bf2d8f5e649389d27d61cbb18c63c112237be0b71663f6e9c

As see files are came to directory
[root@ip-10-0-2-55 swiggy]# docker exec -it  container4 bash
root@7d6cf0703787:/# cd /vakatisubbu/docker/
root@7d6cf0703787:/vakatisubbu/docker# ls
app.py  index.jsp  scripts.sh

Step3: planning create some file to container4 new directory, need to check ,local host /swiggy folder
file are coming or not 

root@7d6cf0703787:/vakatisubbu/docker# touch dockfile jenkins one.yaml
root@7d6cf0703787:/vakatisubbu/docker# ls
app.py  dockfile  index.jsp  jenkins  one.yaml  scripts.sh
root@7d6cf0703787:/vakatisubbu/docker#
exit

Step4: As see file are coming 
[root@ip-10-0-2-55 swiggy]# ls
app.py  dockfile  index.jsp  jenkins  one.yaml  scripts.sh


Real time examples 

Step1: remove the existing containers

[root@ip-10-0-2-55 swiggy]# docker rm -f container4  container3

Step2: remove the existing volumes
[root@ip-10-0-2-55 swiggy]# docker volume rm myapp volume1
myapp
volume1
[root@ip-10-0-2-55 swiggy]# docker volume ls
DRIVER    VOLUME NAME

Step3: Create some file to volume 
[root@ip-10-0-2-55 swiggy]# docker volume create swiggy
swiggy
[root@ip-10-0-2-55 docker]# cd /var/lib/docker/volumes/swiggy/_data
[root@ip-10-0-2-55 _data]# ls
[root@ip-10-0-2-55 _data]# vi index.html
[root@ip-10-0-2-55 _data]# cat index.html
<h1> Welcome to Swiggy app </h1>

Step4: Now planning to mount the container these data volume, here nginx is image 

[root@ip-10-0-2-55 _data]# docker run -itd --name container1 -p 1111:80 --mount src=swiggy,destination=/usr/share/nginx/html nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
59e22667830b: Pull complete
140da4f89dcb: Pull complete
96e47e70491e: Pull complete
2ef442a3816e: Pull complete
4b1e45a9989f: Pull complete
1d9f51194194: Pull complete
f30ffbee4c54: Pull complete
Digest: sha256:84ec966e61a8c7846f509da7eb081c55c1d56817448728924a87ab32f12a72fb
Status: Downloaded newer image for nginx:latest
8060c2c3416419f05ce44cdde47143a5beffe883b14fb2b50d673627e1ce9078

Step5:

Step6: Now we planning to change the text ,in volume in index.html 
automatically will change nginx file path

[root@ip-10-0-2-55 _data]# pwd
/var/lib/docker/volumes/swiggy/_data
[root@ip-10-0-2-55 _data]# cat index.html
<h1> Welcome to Swiggy app Subbu </h1>


Project  (Host to container)

Step1: Git installation completed 
yum install git -y 

Step2: clone the sample index.html page git project to local 

[root@ip-10-0-2-55 ~]# git clone https://github.com/Vakatisubbu/website.git
Cloning into 'website'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (3/3), done.


Step2: now application need to check deployed or not 

[root@ip-10-0-2-55 website]# docker run -itd --name container2 -p 2222:80 -v "$(pwd)":/usr/share/nginx/html nginx
8c637a5a57a3c500716bcdeae77589d6b8b2010b32d91804fa5acb258c9557fe

Step3:  Application deployed successfully.



Now we are planning to do integrate docker services

Step1:

Docker Swarm , here we have taken only one server 

[ec2-user@ip-10-0-2-55 ~]$ sudo -i
[root@ip-10-0-2-55 ~]# docker swarm init
Swarm initialized: current node (1sctotlqzvf76or2iipcjw097) is now a manager.

To add a worker to this swarm, run the following command:

docker swarm join --token SWMTKN-1-4vianq32px0bttucbwq3fse7vdk8u3peaabtlg9kda20ubb3xb-crbohnev80p7knr5p5ahgi3pj 10.0.2.55:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.


Step2: Two containers are created, both container same application page is running 

[root@ip-10-0-2-55 ~]# docker service create --name website --replicas 2 --publish 3333:80 --mount src=swiggy,destination=/usr/share/nginx/html/ nginx
ohdb5kciwvt9jhdbz47lumiwy
overall progress: 2 out of 2 tasks
1/2: running   [==================================================>]
2/2: running   [==================================================>]
verify: Service converged

These below two container just created 
[root@ip-10-0-2-55 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS              PORTS                                   NAMES
5a03d87798ed   nginx:latest   "/docker-entrypoint.…"   About a minute ago   Up About a minute   80/tcp                                  website.1.jc21ky4sf0ooitn573lm3ys7d
8d04a9aa8f55   nginx:latest   "/docker-entrypoint.…"   About a minute ago   Up About a minute   80/tcp                                  website.2.lz11fgnhpaar743b230gi161f

Step3: Need to check whether application 3333 working fine or not 


Step4: Now planning  add some text in data volume 

[root@ip-10-0-2-55 _data]#  vi index.html
[root@ip-10-0-2-55 _data]# pwd
/var/lib/docker/volumes/swiggy/_data
[root@ip-10-0-2-55 _data]# cat index.html
<h1> Welcome to Swiggy app Subbu </h1>
<h1> Welcome to Swiggy Transactions </h1>
<h1> Welcome to Swiggy Orders </h1>
<h1> Welcome to Swiggy Delivered </h1>

Step5: Updated successfully.



How help docker command 

For List of Images 
[root@ip-10-0-2-55 _data]# docker image

Usage:  docker image COMMAND

Manage images

Commands:
  build       Build an image from a Dockerfile
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Display detailed information on one or more images
  load        Load an image from a tar archive or STDIN
  ls          List images
  prune       Remove unused images
  pull        Download an image from a registry
  push        Upload an image to a registry
  rm          Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

Run 'docker image COMMAND --help' for more information on a command.


For List of Network

[root@ip-10-0-2-55 _data]# docker network

Usage:  docker network COMMAND

Manage networks

Commands:
  connect     Connect a container to a network
  create      Create a network
  disconnect  Disconnect a container from a network
  inspect     Display detailed information on one or more networks
  ls          List networks
  prune       Remove all unused networks
  rm          Remove one or more networks

Run 'docker network COMMAND --help' for more information on a command.


For List of volume

[root@ip-10-0-2-55 _data]# docker volume

Usage:  docker volume COMMAND

Manage volumes

Commands:
  create      Create a volume
  inspect     Display detailed information on one or more volumes
  ls          List volumes
  prune       Remove unused local volumes
  rm          Remove one or more volumes
  update      Update a volume (cluster volumes only)

Run 'docker volume COMMAND --help' for more information on a command.



Reference :Document with examples 



https://docker77.hashnode.dev/docker-volumes-with-real-time-examples



--Thanks