Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
22 views3 pages

Containers Qs EX200

The document outlines the steps to build and run a container named 'monitor' using a specified Containerfile, including necessary SSH commands and login credentials. It also details the configuration of host directories for persistent storage and the creation of a systemd service to ensure the container runs continuously. Finally, it instructs on enabling the service and rebooting the system to apply changes.

Uploaded by

chanduspam20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Containers Qs EX200

The document outlines the steps to build and run a container named 'monitor' using a specified Containerfile, including necessary SSH commands and login credentials. It also details the configuration of host directories for persistent storage and the creation of a systemd service to ensure the container runs continuously. Finally, it instructs on enabling the service and rebooting the system to apply changes.

Uploaded by

chanduspam20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1) Build monitor container image with the given Containerfile

http://materials.example.com/Containerfile

Create a container named monitor

ssh root@servera
[root@servera ~]# yum install -y container-tools

[root@servera ~]# ctrl +d --> To exit

Note: You must do ssh to the user(username you can find username details in 2nd
Question),
don't switch to user using su - neil
In Exam read clearly Additional/Important Info to understand about username to execute
container using neil and password is Flectrag

ssh neil@servera
[neil@servera ~]$

Log in to the container registry using the podman login command.


(In exam, Read Additional/Important Info to understand registry server URL, username
and password details)

[neil@servera ~]$ podman login registry.lab.example.com


Username: admin
Password: redhat321

[neil@servera ~]$ wget http://materials.example.com/Containerfile


[neil@servera ~]$ ls -l
[neil@servera ~]$ podman build -t monitor .
[neil@servera ~]$ podman images
[neil@servera ~]$ podman run -d --name monitor monitor

Note: loginctl enable-linger <username> to run container after changing user

[neil@servera ~]$ loginctl enable-linger neil


[neil@servera ~]$ podman ps
2) Configure your host incoming /opt/inbound and outgoing /opt/outbound to
store all journal across reboot.

Configure persistent volume /opt/inbound host folder to the /opt/incoming


container folder and /opt/outbound host folder to the /opt/outgoing
container folder.

When the container starts create container-logserver.service to run the


container persistently with “neil” user credentials.

Check for host dirs


[neil@servera ~]$ ls -ld /opt/inbound /opt/outbound

Note: If given dirs doesn't exists, create it otherwise check ownership of the folder

[neil@servera ~]$ sudo -i or su -

[root@servera ~]# mkdir -p /opt/inbound /opt/outbound


[root@servera ~]# chown neil:neil /opt/inbound
[root@servera ~]# chown neil:neil /opt/outbound

[root@servera ~]# ctrl+d --> To exit

ssh neil@servera

[neil@servera ~]$
podman run -d --name logserver -v /opt/inbound:/opt/incoming:z -v
/opt/outbound:/opt/outgoing:z monitor

Note: Container Name logserver, why because When the container starts create
container-logserver.service

[neil@servera ~]$ podman ps


[neil@servera ~]$ mkdir -p .config/systemd/user
[neil@servera ~]$ cd .config/systemd/user

[neil@servera user]$
[neil@servera user]$ podman generate systemd --help | more

[neil@servera user]$ podman generate systemd --name logserver --files --new


[neil@servera user]$ system --user daemon-reload

[containers@servera user]$ systemctl --user enable container-logserver.service

[containers@servera user]$ su -

[root@servera ~]# reboot

You might also like