What is Docker –
- Docker is a Open-Source centralized platform management tool. Docker is one of the most popular tool as compare with other comparative tools for manage containers.
- Docker is easiest way to create, deploy and run application on containers.
- Docker use a container to manage OS to run any application, container is access system resources form the Linux Kernel instead of allocation fix hardware like virtual machine. docker run natively on Linux distributions, so better performance and result always recommended to use docker on any linux OS.
- Docker application tool written in “go” programming language, which is initially develop for the write programs for the network infrastructure management.
- Docker tool create OS level virtualization, that we well known as a containerization.
- Docker solve so may real environment issues of developer to run application on various platform, lightweight solutions system admin, better resource management system for virtualization with container etc.
- Docker was developed by Solomon Hykes and Sebastien Pahl, it was release in March 2013.
- Docker is Platform As a Service that provide OS level virtualization.
For Free Demo classes Call: 7798058777
Registration Link: Click Here!
Docker Container –
- Container is similar like Virtual Machine to setup OS
- It hold the all required or dependency packages to run any application.
- Docker run application on container
- Docker container is lightweight solution for our virtualization requirement.
- We can easily convert container into image and send to others.
- Once docker run that image it convert into container.
Advantages of Docker –
- Docker take very less time to create container
- Docker does not allocate the fix resources of host system
- It is one of best light weight solution for virtualization
- Less cost
- It can implement of Physical hardware, Virtual Hardware (machine) and in cloud base system also work sufficiently.
- We can re-use the image as per requirement
- Rebuild new images easy process
- Very less time required to stop or start container
For Free Demo classes Call: 7798058777
Registration Link: Click Here!
Steps for Dockers Management –
Use OS: amazon ami linux 2
Step1:
First verify you have docker installed or not
#docker –version
Or
#rpm -q docker
Step2:
To install docker use following command
#yum update -y
#yum install docker -y
Step3:
Now again verify docker successfully installed or which version you is installed
#docker –version
To check where store the docker files
#which docker
Strep4:
For show docker service status
#systemctl status docker
To start docker service
#systemctl start docker
For permanent on docker service ( each boot start )
#systemctl enable docker
Strep5:
For pull ubuntu image from docker hub
#docker pull ubuntu
#docker pull centos
Strep6:
For show docker images
#docker images
Strep7:
For start docker image into container
#docker run -it ubuntu /bin/bash
For check ubuntu version
root@cid# cat /etc/os-release
root@cid# ls
For exit container (stop)
root@cid# exit
Strep8:
For show running docker process
#docker ps
For show runnning and stop docker process
#docker ps -a
Strep9:
if we want to login into existing container
#docker ps -a
#docker start indian_angel
For go inside into docker
#docker attach indian_angel
root@cid# ls
root@cid# exit
Step10:
For remove existing container (stop container)
#docker ps -a
#docker rm indian_angel
#docker ps -a
Step11:
For remove docker images
#docker images
#docker rmi Ubuntu
Step12:
For start container with customization name
#docker run -it –name testcon ubuntu /bin/bash
Step13:
Create content inside the container
#mkdir /aaa
#mkdir /red
#touch /aaa/note{1..5}.txt
#exit
For Free Demo classes Call: 7798058777
Registration Link: Click Here!
Step14:
To check difference between ubuntu original image and new create testcon container image
#docker diff testcon
C /root
A /root/.bash_history
A /red
A /aaa
A /aaa/note4.txt
A /aaa/note5.txt
A /aaa/note1.txt
A /aaa/note2.txt
A /aaa/note3.txt
Note:
C: changes
A: add (addition)
Step15:
For create new self image of testcon container
#docker commit <container-name> <new-image-name>
#docker commit testcon testimage
Step16:
For create container from new created image
#docker run -it –name testimagecon testimage /bin/bash
#ls /aaa
For create container from Docker
- Create docker file
#vim Dockerfile
#vim Dockerfile
FROM Ubuntu
RUN echo “welcome to docker” > /home/welcome.txt
:wq
- To create image of dockerfile
#docker build -t myimage .
#docker ps -a
#docker images
- for start new created docker image
#docker run -it –name myicon myimage /bin/bash
#cd /home
#cat welcome.txt
#exit
now, create new Dockerfile(update existing)
vim Dockerfile
#vim Dockerfile
#ls
#cat > testfile1
#docker build -t myimage1.
#docker images
#docker run -it –name myicon1 myimage1 /bin/bash
#pwd
#ls
#exit
Steps For Manage Docker Volume:
For pull ubuntu image from docker hub
#docker pull ubuntu
#docker pull centos
For show docker images
#docker images
For volume
step1:
For create docker file
#vim Dockerfile
FROM ubuntu
VOLUME [“/mydata”]
:wq
step2:
For build docker image
#docker build -t myimage .
For show docker image
#docker images
step3:
create container from myimage
#dcoker run -it –name con1 myimage /bin/bash
root@cid# ls
root@cid# cd /mydata
root@cid# ls
root@cid# touch con1{a..e}.txt
step4:
For share volume (/mydata) with new container
#docker run -it –name con2 –privileged=true –volumes-from con1 ubuntu /bin/bash
root@cid# ls
root@cid# cd /mydata
root@cid# ls
root@cid# touch con2{a..e}.txt
root@cid# ls
root@cid# exit
Step5:
Start container con1 and verify con2 created data available or not
#docker ps -a
#docker start con1
#docker attach con1
root@cid# ls
root@cid# cd /mydata
root@cid# ls
root@cid# exit
step6:
For share volume (/mydata) with new container con3
#docker run -it –name con3 –privileged=true –volumes-from con2 ubuntu /bin/bash
root@cid# ls
root@cid# cd /mydata
root@cid# ls
root@cid# touch con3{a..e}.txt
root@cid# ls
root@cid# exit
Step7:
Start container con1 to verify con3 created data available or not
#docker ps -a
#docker start con1
#docker attach con1
root@cid# ls
root@cid# cd /mydata
root@cid# ls
root@cid# exit
Map Volume Host OS to container
Step1:
Create directory for volume
#mkdir pune
#pwd
#/root/pune
Step2:
Map pune volume with container
#docker run -it –name mycon1 -v /root/pune:/mypune –privileged=true ubuntu /bin/bash
root@cid# ls
root@cid# cd /mypune
root@cid# touch mycon1{a..e}.txt
root@cid# ls
root@cid# exit
step3:
check hosts os directory pune
#cd /root/pune
#ls
all content available create in container
step4:
create content in host os
#cd /root/pune
#ls
#touch hostos{1..5}.txt
#ls
Step5:
Check content inside the container
#docker start mycon1
#docker attach mycon1
root@cid# cd /mypune
root@cid# ls
root@cid# exit
For Free Demo classes Call: 7798058777
Registration Link: Click Here!
Web hosting in container
docker run -dt –name webcon -p 80:80 ubuntu
#docker ps
#docker stop icon1
#docker ps
#docker exec -it webcon /bin/bash
#docker port webcon
#docker exec -it webcon /bin/bash
Author:-
Abhijit Dahatonde
Call the Trainer and Book your free demo Class Call now!!!
| SevenMentor Pvt Ltd.
© Copyright 2021 | Sevenmentor Pvt Ltd.