Docker Commands
Docker Commands
→Basic process commands: - how to create images and how to crate container
yum update -y = files ni update cheystundi
yum install docker -y = docker install avthundi docker linux machine lo leka poty
wget tho download cheyachu
which docker = docker
docker -v = version check cheyali anukunte
docker --version
service docker status = inactive lo vutundi
docker info
service docker start = active avthundi
docker images = images ante like ubuntu Jenkins docker (docker hub lo
emina download cheyste chupistundi)
docker ps (process status-full form) = important command container check
cheyadaniki (start lo vuna containers
chupistundi)
docker ps -a = hidden chupistundi (stop cheysina containers and run lo vuna
containers chupistundi)
docker search ubuntu = docker hub nudi velakunda cmd dawra images check
cheyali anukunte linux-machine lo e cmd
docker pull ubuntu = ubuntu image ni download cheystundi
docker pull redis____docker pull centos____docker pull jenkins_____etc
docker run -it ubuntu /bin/bash = e command tho docker hub nudi pull cheysi
download cheystundi and container lo direct velalli anukunte cmd
cat /etc/os-release = ani detailes chupistundi ubuntu operating system version
ani
docker run -it ubuntu /bin/bash = again e cmd type cheyste new container ni
create cheystundi ani sarllu e cmd type cheystamo ani sarllu new container ni
create cheystundi
docker run -it --name kareem ubuntu /bin/bash = container name evali anukunte
new container ke matrame e cmd (real time lo use cheyse cmd)
docker run -it --name kareem ubuntu “touch f1” = e cmd tho manom name and
bin/bash name change cheyali anukunte cmd
Container nudi bayatike ravali ante = exit type cheyste challu
Container lo vunam ani ela telustundi ante (ec2-user lo root@bg9ab9aa4df3:/ane id
chupistundi)
docker start kareem = stop cheysina container ni start cheyali anukunte
docker attach kareem = start ayina container lopalike velali anukunte
docker stop kareem = stop cheyali anukunte cmd
docker rm kareem = container ni delete cheyali anukunte cmd and run lo vuna
container delete avadu stop cheysi delete cheyali
docker rmi (ID) = image ni delete cheyali anukunte command
docker rmi -f $(docker images -q) = all images ni delete cheyali anukunte
Second Script :-
FROM ubuntu
WORKDIR /tmp
RUN echo “this is kareem file” > /tmp/testfile1
ENV name kareem
COPY file1 /tmp
ADD test.tar.gz /tmp
Copy ke voka file create cheystom “touch file1” appudu e copy sample kuda work
avthhundi. Kani add sample ke china process vundi kavali ante youtube chudali.
edi second script anadi first script ni erase cheysi type cheyali ‘Dockerfile’ lo inka
samples google cheyste dorukutai
Dockerfile__________image__________container (e three steps cheystam)
dockerfile components :-
1. FROM :for base image this command must be on top of the file.
2. RUN :to execute commands, it will create a layer in file.
3. Copy :copy files from local system.
4. ADD :it can download files from internet and also. We can extract file at
docker image side.
5. EXOPSE :to expose ports such as 8080 for tomcat and port 80 for nginx etc.
6. WORKDIR :to set working directory for the container.
7. ENV :environment variables.
1. Auto machine
vim Dockerfile = docker file vokati create cheystam “docker file lo capital D ne
evali”
script rayali :-
FROM ubuntu
VOLUME [“/kareem”]
RUN touch file1
docker build -t image1 . = image ni build cheystam (. Ante present directory ani
ardham)
docker run -it --name container1 image1 /bin/bash = container create cheystom
ls = ani esty file1 and kareem volume chupistundi container lo
kareem volume lo velli edina files create cheystom
→(container1 lo vuna volume ni vere container ke share cheyali anukunte process):-
docker run -it --name container2 --privileged=true --volumes-from container1
image1 /bin/bash = first new container name evali and volumes-from lo manom
first create cheysina volume container name and image name evali
and “cd kareem” volume lo veli check cheyste files chupistundi. Manom container2
volume lo edina changes cheyste adi container1 lo vuna volume lo kuda reflect avthundi
2. Manual
Docker run -it --name container3 -v /kareem-1 image1 /bin/bash = new container
name evali “container3” and new volume name “kareem-1” and manom create
cheysina image name evali “image1”anadi manom already create cheysindi evali
ls = ani iche check cheyste manaki volume chupistundi “kareem-1” tarvata voka file
create cheystom
→(container3 lo vuna volume ni vere container ke share cheyali anukunte manual
Process lo):-
Docker run -it --name container4 --privileged=true --volumes-from conatiner3
image1 /bin/bash = vere container ke share cheyali anukunte cmd
3. Hostvolume
Docker run -it --name hostcontainer -v /home/ec2-user:/hostvolume ubuntu
/bin/bash = local lo vuna files ni container lo save cheyali anukunte cmd. First new
container name and local files path “home/ec2-user” and volume name “ex:-
hostname” and image name “ubuntu”
and another ec2-instance create cheystom region vachi virginia teskunom (docker install
cheysi start cheyali)
docker pull kareem/project1 = pull cheyadaniki command (image chupiistundi)
docker run -it --name container1 kareem/project1 /bin/bash = container ni crea
te chaistom (ls cheyste files ani chupistundi)
na image ni private kuda cheyachu and image ni mala acces cheyali ante login
ayi pull cmd type cheyste work avthundi
THE END