RHCSA RHEL 8 - Containers Continued

Описание к видео RHCSA RHEL 8 - Containers Continued

Your support on Ko-Fi is much appreciated:
👉 https://ko-fi.com/csg_yt

Join our new discord channel:
👉   / discord  

Buy CSG Merchandise:
👉 http://tee.pub/lic/csg

This video is based on RHEL 8.

Video to cover the section 'Containers' for the RHCSA (Red Hat Certified System Administrator).

More information on the required learning: http://bit.ly/rhcsa8

Notes from the video:

1. Inspect Container Images:

Local images:
podman inspect docker.io/library/httpd

Remote images:
Install skopeo:
dnf install skopeo
Inspect remotely:
skopeo inspect docker://registry.fedoraproject.org/fedora:latest

2. Configure a container to start automatically as a systemd service:

Firstly need to enable the boolean for selinux to allow the execution of a container via systemd:
setsebool -P container_manage_cgroup on

Then we need to run the container once to give it a name:
podman run -d --name httpd-server -p 8080:80 httpd

Then we need to create the service defintion for systemd to be able to start the container:
vim /etc/systemd/system/httpd-container.service

It should look like this:
[Unit]
Description=httpd Container Service
Wants=syslog.service

[Service]
Restart=always
ExecStart=/usr/bin/podman start -a httpd-server
ExecStop=/usr/bin/podman stop -t 2 httpd-server

[Install]
WantedBy=multi-user.target

One done you can use the standard systemctl commands to start/stop/enable the service:
systemctl start httpd-container.service
systemctl status httpd-container.service
systemctl enable httpd-container.service

3. Run a Service inside a container:

Using a Dockerfile (this allows us to add additional files/applications to our container image):
vim Dockerfile
It should look like this:
FROM registry.access.redhat.com/ubi8/ubi-init
RUN yum -y install httpd; yum clean all; systemctl enable httpd;
RUN echo "Successful Web Server Test" redirect-to /var/www/html/index.html
RUN mkdir /etc/systemd/system/httpd.service.d/; echo -e '[Service]\nRestart=always' redirect-to /etc/systemd/system/httpd.service.d/httpd.conf
EXPOSE 80

Then to build the container image (mysysd is the name):
podman build -t mysysd .

We can then run the container:
podman run -d --name=mysysd_run -p 80:80 mysysd

Check status:
podman ps

4. Attach persistent storage to a container:

Make a directory that the container will mount to:
mkdir /home/cengland/containers/disk1

Run the container with the priviledge command and -v option to mount (additional -it and /bin/bash to allow us to connect to terminal):
podman run --privileged -it -v /home/cengland/containers/disk1:/mnt httpd-server /bin/bash

Can confirm the mount by using at the containers shell:
df -h


#rhcsa #rhel #linux #redhat

Комментарии

Информация по комментариям в разработке