Openshift Training Command

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

26-04-2021

------------------
DO180 part of containers + openshift

cmd >ssh -i linux3podohio.pem [email protected]

>Yes
>who am i

docker/podman
vmwere
kernel

yum install podman -y


uname -r : to check the kernel
podman

yum install bash-completion -y

bash

podman info :each and every details of podman

check images : podman images

search image : podman search hello-world

Download: podman pull <docker.io/library/hello-world

podman images

create container: podman run <hello-world>


how many containers running : podman ps
all check running stop : podman ps -a

customize name container: podman run --name tcs1 hello-world

27-04-2021
-------------------
Interactive terminal: podman run -i -t centos
ls -l
exit
Enter into container: docker/podman attach <container name>

New name: podman run -it --name container2 centos


To run container trick: CTRL+PQ
To run a new command inside ur container: podman exec -it container2 bash
Help to find: podman --help | grep detach
Run in background: podman run -itd centos
Automatically stop all containers: podman run -itd --name priyapolicy1 --restart
always centos
To start a container: podman start <containername>
To stop a container: podman stop <containername>
Details about container: podman inspect <runningcontainername>
Remove docker images: podman rmi <imagename> -f
Delete Container:
Ubuntu command: >etc/sourceslist/ > apt-get update vsftp
How to create your web application in ur container: podman run -it --name webserver
centos
with port number: podman run -it --name
webserver12 -p 5000:80 nginx
to check: cd /etc/yum.repos.d/
Apache: yum install httpd -y
/var/www/html
vi index.html
<h1>Hello Openshift</h1>
:wq
cat /var/www/html/index.html
systemctl start httpd
systmctl status httpd
Two command to run html page inside docker: httpd -DFOREGROUND
httpd -DBACKGROUND
To run directly in terminal: curl <ip>
How to create the image from running container: podman export webserver10 -o
test_v1.tar

podman export pr.tar new:b1

28-04-2021
-----------------------------------------------------
Q1)
podman run -it --name webserver11 -p 3354:80 centos
yum install httpd -y
cd /var/www/html/
echo Hello World > index.html
httpd: -DBACKGROUND
create Tar file: podman export webserver2 -o test1.tar (if it will not work delete
a file)
Import: podman import test1.tar test:v1

Q2

podman save httpd -o check.tar


ls
podman load -i check.tar
change tag: podman tag httpd check:v1

Dockerfile:
mkdir docker
ls
vim Dockerfile
FROM centos (image)
MAINTAINER [email protected] (name or email)
RUN - run commands inside image/container yum install httpd -y
COPY dev.html /var/www/html/ echo Hello World >
/var/www/html/index.html
CMD - run the commands ur going to run starting time httpd -DFOREGROUND
ENTRYPOINT - Each and every time if u want to run
EXPOSE - port expose 80
ADD cool.
WORKDIR - which dir u wants to work as /usr/share/nginx/html

creating a image from docker file: podman build -t custom:latest .


how a image created automatically: podman history centos
one command to delet all container: podman ps -qa
podman rm -f $(podman ps -qa)
podman rmi -a
all images delete one go: podman images -q
podman rmi -f $(podman images -q)
podman rm -a

Docker swarm
---------------
how to create cluster of docker swarm : docker swarm init --advertise-addr
3.14.149.168

Service create: docker service create -p 3333:80 --name mynginx nginx


verify list: docker service ls
container create: docker service <mynginx>

You might also like