Podman 101: Practical Labs

    podman logo

What is Podman? Podman is a daemonless container engine for developing, managing, and running OCI Containers on your Linux System.

Example:
 1- Deploy Apache web server on podman:
 2- Create volume persistent and join  with podman.
 3- Test web server access.
 4- Change index.html and reload podman
 5- Test changed.
6-  use  podman as system services.

[root@podman ~]#   mkdir -p /opt/var/www/html
 [root@podman ~]#  cd /opt/var/www/html
 [root@podman html]# wget --page-requisites --convert-links https://registry.fedoraproject.org/
 [root@podman html]# chown 1001 -R /opt/var
 [root@podman ~]#   mkdir -p /opt/var/www/html
 Create podman with local volume persistent:
[root@podman html]#  podman run -d --name myhttpservice -p 8080:8080 -v                               /opt/var/www/html:/var/www/html:Z    registry.fedoraproject.org/f29/httpd
[root@podman html]#  podman   logs  -f   myhttpservice
172.250.1.32 - - [18/Sep/2019:11:06:36 +0000] "GET /registry.fedoraproject.org/ HTTP/1.1" 200 164657 "-" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
172.250.1.32 - - [18/Sep/2019:11:06:36 +0000] "GET /registry.fedoraproject.org/css/styles.css HTTP/1.1" 200 5735 "http://172.250.1.157:8080/registry.fedoraproject.org/" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
172.250.1.32 - - [18/Sep/2019:11:06:36 +0000] "GET /registry.fedoraproject.org/fedora.png HTTP/1.1" 200 6265 "http://172.250.1.157:8080/registry.fedoraproject.org/" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
172.250.1.32 - - [18/Sep/2019:11:06:37 +0000] "GET /registry.fedoraproject.org/js/scripts.js HTTP/1.1" 200 3132 "http://172.250.1.157:8080/registry.fedoraproject.org/" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
172.250.1.32 - - [18/Sep/2019:11:06:37 +0000] "GET /registry.fedoraproject.org/css/search.svg HTTP/1.1" 200 1321 "http://172.250.1.157:8080/registry.fedoraproject.org/css/styles.css" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"


 Open http://localhost:8080/registry.fedoraproject.org in your Web Browser:



Change index.html:




EXAMPLE: System Services in Containers:

Why not use container as system services:

[root@Podman ~]#  vi /etc/systemd/system/myhttpservice.service
-----
[Unit]
Description=Just and http service with Podman Container
[Service]
Type=simple
TimeoutStartSec=30s
ExecStartPre=-/usr/bin/podman rm "myhttpservice"
ExecStart=/usr/bin/podman run --name myhttpservice -p 8080:8080 -v /opt/var/www/html:/var/www/html:Z registry.fedoraproject.org/f29/httpd
ExecReload=-/usr/bin/podman stop "myhttpservice"
ExecReload=-/usr/bin/podman rm "myhttpservice"
ExecStop=-/usr/bin/podman stop "myhttpservice"
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
-------- 

[root@Podman ~]#  systemctl daemon-reload
[root@Podman ~]#  systemctl status myhttpservice.service
 myhttpservice.service - Just and http service with Podman Container
   Loaded: loaded (/etc/systemd/system/myhttpservice.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

[root@Podman ~]#  systemctl start myhttpservice.service
[root@Podman ~]#  systemctl status myhttpservice.service
myhttpservice.service - Just and http service with Podman Container
   Loaded: loaded (/etc/systemd/system/myhttpservice.service; disabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Sun 2019-09-22 10:16:04 EET; 15s ago
  Process: 8140 ExecStart=/usr/bin/podman run --name myhttpservice -p 8080:8080 -v /opt/var/www/html:/var/www/html:Z registry.fedora>
  Process: 8114 ExecStartPre=/usr/bin/podman rm myhttpservice (code=exited, status=125)
 Main PID: 8140 (code=exited, status=125)

### Open http://localhost:8080/registry.fedoraproject.org in your Web Browser



------------------------------------------------------------------------------------
Good Luck https://www.linkedin.com/in/ahmedms/

Comments

Popular posts from this blog

Kubernetes 104: Create a 2-node k3s cluster with k3sup

Cisco Nexus: Configuration VXLAN.

How to configure OSPF on Palo Alto Networks Firewall?