--Search - download docker desktop for windows
--Docker Hub Login:
https://id.docker.com/login
Docker Commands:
docker top ContainerID
docker stop ContainerID
docker stats ContainterID
docker attach ContainterID
docker pause ContainterID
docker unpause ContainterID
docker kill ContainterID
Examples:
C:\Users\subas.patel>docker run hello-world
C:\Users\subas.patel>docker container ls --all
Dt:21-02-2023:
--Create Mongo DB Image:
docker run -d -p 27017:27017 --name test-mongo mongo:latest
--For specific mongodb version:
docker run -d --name test-mongo mongo:4.0.4
docker exec -it test-mongo bash
docker logs test-mongo --follow
--To create network Image:
docker network create test-network
docker network ls
docker inspect bridge
docker network connect test-network test-mongo
docker stop test-mongo
docker start test-mongo
--To delete Instances:
docker stop test-mongo
docker rm test-mongo
--To see Volume lists:
docker volume ls
docker run -d -p 27017:27017 --name test-mongo -v data-vol:/data/db mongo:latest
docker run -d -p 27017:27017 --name test-mongo -v mongo-data:/data/db -e MONGODB_INITDB_ROOT_USERNAME=admin -e MONGODB_INITDB_ROOT_PASSWORD=admin@123 mongo:latest
docker run node:latest(Not working)
docker run -dt --name node-image node:18.0
--Open the VS Code>>Search in Extension "Docker for VS Code" and install>>click on Docker icon will able to see all Docker Images
E.g. Node Image, Mono DB Image
--Right click on Node Image>>Select Attach Shell
--then search in Extension "Dev Containers" and install
--Goto the Terminal of VS Code and create Remote Root Folder>> #mkdir kubernateapi >>#mkdir kubernateapi
--Then Right click on Node Image>>Select Attach VS Code
--It will open VS Code
e.g:/kubernateapi[Container node:18.0 (node image)]/
--then execute below commands:
npm i express nodemon mongoose --save
npm i mongoose --save
Dt-22/02/2023:-
>docker network create nodeapi-mongo-network
>docker network connect nodeapi-mongo-network node-image
>docker network ls
>docker network nodeapi-mongo-network
>docker network connect nodeapi-mongo-network test-mongo
>docker network inspect nodeapi-mongo-network
--Go to Docker Terminal:
#mongosh
test>use EmpDB
EmpDB>db.Employee.insertOne({"EmpID":1,"Name":"Som"})
EmpDB>db.Employee.insertOne({"EmpID":2,"Name":"Somi"})
EmpDB>db.Employee.find()
--To add user authentication for MongoDB using Docker:
EmpDB>db.createUser({
user:'admin',
pwd:'admin@123',
roles:[]
});
#npm start
--To check Kubernate is install or not at the time of Docker Installation
C:\Program Files\Docker\Docker\resources\bin
Another way to Install Kubernate:
Goto Right click on Docker>>Settings>>Kubernate>>Select Enable Checbox>>Apply & Restart>>Install
Dt:27-02-2023:-
Kubernate Setup:
Go to Taskbar>>"Show hidden icons" arrow>>Right click "Request administrator access">>Tools>>Uninstall Program
>>then Check the checkbox "Hyper-V"
>>and Check the checkbox "Windows Hypervisor Platform"
>>OK and Restart the system
Make a helpdesk tkt to install Hyper-V s/w
Enable the K- Cluster
>Kubectl
Go to below link>scroll down to installation & download latest .yaml configuration:
https://github.com/kubernetes/dashboard/releases
Get the content from below recommended.yaml and save in your local folder with same extension type by putting double quote as "recommended.yaml" in notepad
https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.0/aio/deploy/recommended.yaml
Deploy it using:
>kubectl apply -f .\recommended.yaml
Verify if its running:
>kubectl.exe get -f .\recommended.yaml.txt
Deploy it using:
>kubectl.exe apply -f .\dashboard-admin.yaml
Generate token using:
>kubectl.exe -n kube-system create token admin-user
Start the Proxy using:
>kubectl proxy
Copy paste the token in below link, it will take it to Kubernate Dashboard:
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
Reference for Kubernative:
https://kubernetes.io/docs/reference/glossary/?all=true#term-image
>kubectl create -f create-testmongopod.yaml
>kubectl get pods
>kubectl describe pods/testmongopod
Container orchestrators:
https://devops.com/characterizing-and-contrasting-container-orchestrators/
Installing Kubernative with kOps:
https://kubernetes.io/docs/setup/production-environment/tools/kops/
Install AWS-Shell:
https://github.com/awslabs/aws-shell
Dt:28-02-2023:-
>docker ps
>docker ps -a
Kubernative is a container management tool
Dt:01-03-2023:
For Reference: Complete course using O'reilly site:-
Docker for the Absolute Beginner - Hands-On
https://learning.oreilly.com/videos/docker-for-the/9781788991315/
Time: 4h 16m
Kubernetes for the Absolute Beginners - Hands-On
https://learning.oreilly.com/videos/kubernetes-for-the/9781838555962/
Time - 5h 42m
Creating a HTML page and pushing our app to Docker
Building Container Images
https://learning.oreilly.com/scenarios/build-container-images/9781492061700/
Time : 10 Mins
This is for Python Developers
Deploying Python APIs on Kubernetes: Deploying a Python Application Using Kubernetes
https://learning.oreilly.com/scenarios/deploying-python-apis/9781492090472/
Time: 10 Minutes
Kubernetes Pipelines: Python Pipeline to Kubernetes
https://learning.oreilly.com/scenarios/kubernetes-pipelines-python/9781492090182/
Time : 30 minutes
Docker from O'reilly:
docker run nginx -----its a existing image from docker container to run
docker ps
docker ps -a
docker stop containername
docker rm containername
docker images
docker rmi nginx
docker pull nginx
docker run ubuntu
docker run ubuntu sleep 5
docker exec containername cat /etc/hosts
docker run kodekloud/simple-webapp -----attached mode --do ctrl+c
docker run -d kodekloud/simple-webapp -----its a dettached mode
docker attach a043d -----first 5 char of containerid
Ex:
root#docker run centos
root#docker run -it centos bash
container# cat /etc/*release* -----show the version detials of running container
exit
clear
docker ps -----list all the running container only
docker run -d centos sleep 20 -----will run in background
docker ps -a -----list all the container
docker stop containername
docker rm containername/containerid
docker rm 345 e0a 773 -----to remove 3 different containers by id of first 3 char
docker images
docker rmi containername -----First detele dependancy container before images
docker ps
docker images
docker pull ubuntu -----its pull the image with out run the container
--To Practice docker command:
https://kodekloud.com/p/docker-labs
--Run-StdIN
docker run -it kodekloud/simple-prompt-docker
--Run-Port mapping:
docker run -p 3306:3306 mysql
docker run -p 8306:3306 mysql
--Run-Volume mapping
docker run -v /opt/datadir:var/lib/mysql mysql
docker inspect containername
docker logs containername
docker run timer
docker run -d timer -----its dettached & running in the background
docker ps
docker attach containerid -----to attach again
Example of Jenkins:
docker run jenkins -----it will pull down the image
docker inspect containerid
--Map Port
docker run -p 8080:8080 jenkins
--Map Volume
docker run -p 8080:8080 -v /root/my-jenkins-data:/var/jenkins_home -u root jenkins
docker build .
docker images
docker push webapp
docker login
docker push webapp
Link:
docker run -d --name=result -p 5001:80 --link db:db result-app
#ls -al -----get the directories
#cd folderpath/
#ls
#cat Dockerfile
#docker build . -t imagename
image: docker.io/nginx/nginx
registry useracc. imagename
Deploy private Registry:
docker run -d -p 5000:5000 --name registry registry:2
docker image tag my-image localhost:5000/my-image
docker push localhost:5000/my-image
docker pull localhost:5000/my-image
docker history imageid
Dt:03-03-2023:-
Kubernate from O'reilly:
Kubectl utility
Hypervisor
VirtualBox
Minikube.exe
>kubectl get nodes
>kubectl version
https://kubernetes.io/docs/tasks/tools/install-kubectl
>minikube start
>minikube status
>kubectl get pods
>kubectl run nginx --image=nginx
>kubectl describe pod nginx
>vim pod.yaml
>cat pod.yaml
>kubectl apply -f pod.yaml
>kubectl edit pod redis
>kubectl replace -f replicaset-definition.yml
>kubectl scale --replicas=6 -f replicaset-definition.yml
>kubectl scale --replicas=6 replicaset myapp-replicaset
>kubectl create -f replicaset-definition.yml
>kubectl get replicaset
>kubectl delete replicaset myapp-replicaset
>kubectl edit replicaset myapp-replicaset
>kubectl scale replicaset myapp-replicaset --replicas=2
>kubectl replace -f replicaset-definition.yml
>kubectl scale --replicas=6 replicaset myapp-replicaset
>kubectl get replicasets
>kubectl describe replicaset
>pwd -----take it to root path
>ls
>cat replicaset-definition-1.yaml -----show desc of yaml file
>kubectl create -f replicaset-definition-1.yml
>vi replicaset-definition-1.yml -----to edit yaml file
>kubectl create -f replicaset-definition-1.yml
>kubectl get rs -----replicaset
>kubectl edit rs new-replica-set
>kubectl get rs new-replica-set -o yaml -----Kubernete will create yaml file for you
>kubectl get rs new-replica-set -o yaml > new-replica-set.yaml
>kubectl scale rs new-replica-set --replicas=5
>kubectl create -f deployment-definition-1.yml
>kubectl get deployments
>kubectl get replicaset
>kubectl get pods
>kubectl describe deployments.apps frontend-deployment | grep -i image
>kubectl describe pod podname
>kubectl create deployment httpd-frontend --image=httpd:2.4-alpine
>kubectl scale deployment --replicas=3
>kubectl scale deployment --replicas=3 httpd-frontend
>kubectl apply -f deployment-definition.yml -----configured
>kubectl set image deployment/myapp-deployment \nginx=nginx:1.9.1 -----image update
>kubectl rollout status deployment/myapp-deployment
>kubectl rollout history deployment/myapp-deployment
>kubectl rollout undo deployment/myapp-deployment
>kubectl run nginx --image=nginx
>kubectl delete deployment myapp-deployment
>kubectl edit deployment myapp-deployment --record
>kubectl rollout history deployment/myapp-deployment deployment.apps/myapp-deployment
>kubectl rollout undo deployment/myapp-deployment
>kubectl get deployments
>kubectl get pods
>kubectl create -f service-definition.yaml
>kubectl get svc
>minikube service myapp-service --url
>kubectl describe svc kubernetes
>kubectl expose deployment simple-webapp-deployment --name=webapp-service --target-port=8080 --type=NpdePort --port=8080 --dry-run=client -o yaml > svc.yaml
>vi svc.yaml
>kubectl apply -f svc.yaml
>kubectl get pods,svc
Using Azure:
Search for AKS and get cluster created
>kubectl get nodes
>git clone https://...
No comments:
Post a Comment