RHCSA stuff 2 Flashcards
Install podman
check version
Check environment and registry\repository info
Look for a specific image in repository
(image - prebuilt containers packed together)
Use highest star image - download
show previously downloaded images
Check running containers
Run container
Check if container is running check via web browser or command
View logs
Stop a running container
How do you run multiple containers of httpd?
Create a new container from the download image
Manage containers through systemd (manages boot processes) (first you’ll need to generate a unit file)
enable the service
yum install podman -y
podman -v
podman info
registries:
search:
- registry.access.redhat.com
- registry.redhat.io
- docker.io
If you’re looking for specific image, it will look in the above order
podman search httpd
podman pull docker.io/library/httpd (or whatever you want)
podman images
podman ps
podman run -dt -p 8080:80/tcp docker.io/library/httpd
(-d detach/daemon mode - runs in background, -t give it a terminal, -p expose port from host to container so we want container listening on container, this gives it its own httpd instance)
podman ps
localhost:8080
pogman logs -l
podman ps (container id will be first collumn)
podman stop (container-id)
Change the port to run multiple containers:
podman run -dt -p 8081:80/tcp docker.io/library/httpd
podman run -dt -p 8082:80/tcp docker.io/library/httpd
podman create –name nates_httpd docker.io/library/httpd (last part is the registry) <- creates image
podman start nates_httpd <- starts container
podman generate systemd –new –files –name nates-httpd (generates unit file)
If you don’t get the message that it’s in /etc/systemd/system then it’s in /root
systemctl enable/start container-httpd.service (whatever it’s acalled in /etc/systemd/system)
TO DELETE CONTAINER
Show logs for a container
podman logs amazing_juan
Remove a container
podman rm farting_bear
What is port binding on podman
8080:80
host port : container port
I want httpd ran on 8080 on my host
Show all containers that have been run on podman
podman ps -a
How do we make an interactive ubuntu container
podman -it -d -p 8080:80 ubuntu
podman attach (container id)
ctrl + p then q to leave
Install on ubuntu container
install updates and apache2 (httpd)
verify it’s running
create an image of the container so it saves
Create a container that’s saved
podman pull ubuntu
podman run -it ubuntu /bin/bash
apt update apache2 -y
apt dist-upgrade
/etc/init.d/apache2 status
/etc/init.d/apache2 start
CTRL + p (let got of P) q
podman commit (container id) apache-test:1.0 (version number not necessary)
Oh no! it doesn’t pull up the web page!
podman commit (containerid) –change=’ENTRYPOINT [“apachectl”, “-DFOREGROUND” (new container id)
apache-test:1.1
TRY THIS INSTEAD
podman commit (containerid) (newcontainerid) change=’CMD [“apachectl”, “-DFOREGROUND”]’
Now create a container
podman create –name nathan_container -p 8080:80 nathan
if ENTRYPOINT doesn’t work use CMD (this will save you a lot of frustration)
ENTRYPOINT - this is another word for the first thing the container does upon loading.
Build a docker file
mkdir dockerfiles
cd dockerfiles
vi Dockerfile
FROM ubuntu (the container you want to create image from)
MAINTAINER Nathan joshcahoe@gmail.com
Update packages
RUN apt update; apt dist-upgrade -y
Install packages
RUN apt install -y apache2 vim-nox
Set entrypoint
ENTRYPOINT apache2ctl -D FORGROUND
if ENTRYPOINT doesn’t work use CMD
podman build -t lltv/apache-test:1.2 .
-t means tag
. means find the dockerfile in current directory
(if ubuntu prompts for date and time settings add this)
ARG DEBIAN_FRONTEND=noninteractive
Create a container out of your working apache server and assign it port 8081
Next turn it into a service you can turn on
podman create –name nathan -p 8081:80 apache_server
podman generate systemd –new –files –name apache_server
the podman container has to be running in order to create the systemd service
Look at the ubuntu image via skopeo
skopeo inspect docker://docker.io/library/ubuntu
skopeo list tags docker://docker.io/library/ubuntu
/dev/sdb1 has an xfs file system, check if it’s functioning properly then return the exit code
xfs_repair
echo $?
Show what run-level you’re in
who -r
Describe the linux boot process
Power Button Pressed
BIOS (basic input output system) -
performs system integrity checks, looks for boot loader (like a Hard Drive or CD)
MBR (Master Boot Record) 1st sector of the disk (like /dev/sda/) Executes GRUB and loads in RAM
GRUB2 (Grand Unified Bootloader) executes kernel - allows you to choose version of kerenel. (/boot/grub/grub.conf or boot/grub2/grub.cfg) YOU WILL SEE GRUB POP UP GIVING YOU KERNEL OPTIONS starts initrd (initial ram disk) temp root file system until kernel is booted
GRUB2 Loads vmlinux or vmlinuz, initrd loads just enough software to recognize your hardware to load full kernel.
/boot/vmlinuz
Kernel - Mounts the root file system from grub.conf. Executes /sbin/init, also loads required drivers from here and start the first OS process systemd.
Systemd the runs init and starts all required processes:
reads = /etc/systemd/system/default.target to bring the system to the run_level
Init - executes run level programs
/sbin/init
Runlevel - /etc/rc.d/rc(number).d/
Configure motd
vi /etc/motd
vi /etc/ssh/sshd_config
Motd - off
vi /etc/profile.d/motd.sh
systemctl restart sshd
3 different ways to view the disk partitions
df -h
fdisk -l
lsblk
Adding a disk
Show added disk
Create new partition
Add file system type (We want linux shit)
Mount that ol’ girl to a directory you make called data
Make it mounted on boot
Unmount
Add hard drive
fdisk -l
fdisk /dev/sdb
n
p (primary)
(enter)
(enter)
+1G (if you wanted to make a 1G partition)
w (write table to disk and exit)
fdisk -l
mkfs.xfs /dev/sdb1 (xfs is linux shit)
mkdir /data
mount /dev/sdb1 /data
vim /etc/fstab
at end:
/dev/sdb1 /data xfs defaults 0 0 (this allows this on boot)
umount /data
You can use UUID located in blkid in /etc/fstab instead of /dev/sdb1
Setup LVM via starting setup
During initial setup:
Select -> Instillation destination
Select : “I will configure partitioning”
New mount points will use the Following partitioning scheme:
LVM
Click the plus
Add the other disk and make sure it’s in the same Volume group (these can be on different mount points)
/
/home
/var
swap
/boot
You can just do one partition under / if you like
start up and:
df -h
/dev/mapper/host123-root (host123 is the name of our LVM volume, if you see this naming convention, this means this is an LVM partition)
Adding Disk and Creating new LVM partition
Add new hard disk
show where it’s located
create partition (make sure you make it LVM)
create a physical volume for it
Create a volume group
Create Logical Volume (or logical partition you could call it)
Mount to directory oracle
Create new disk
fdisk -l (confirm it’s there)
fdisk /dev/sdc
n
p
(enter)
(enter)
(enter)
p (shows info)
t (type of partition)
L (shows hex codes) 8e (Linux LVM)
p (to confirm)
w (to write)
pvcreate /dev/sdc1 (pvcreate - physical volume create)
pvdisplay (shows volumme info)
vgcreate oracle_vg /dev/sdc1 (or whatever name you want)
vgdisplay oracle_vg
lvcreate -n oracle_lv –size 1000M oracle-vg
or (lvcreate -n oracle_lv -l 100%FREE oracle-vg
mkfs.xfs /dev/oracl_vg/oracle_lv
mkdir /oracle
mount /dev/oracle_vg/oracle_lv /oracle
df -h
vim /etc/fstab
add:
/dev/oracle_vg/oracle_lv /oracle/ xfs defaults 0 0