Sharing Ilmu

Sharing for useful things

Configure Persistent Storage web server for container host in Linux Redhat/CentOS

In this tutorial,  I’ll explain about configuration persistent storage webserver on podman container host. In preceding tutorial i’m has been to discuss about How To configure web server with container on Linux CentOS/RedHat with default storage.

For configure persistent storage, create new directory in home directory.

Add new file index.html that containing Text for testing page in website directory.

$  echo “Testing My Persistent storage web server” > ~/website/index.html

Then, login to registry if you need to pull images first.

$  podman login registry.redhat.io

Now, create container with podman and configure persistent storage. When do configure persistent storage that have some format as the follows :

-v host_directory:container_directory:Z

-v (–volume) is option that used for running podman container with specifying directory storage path and container storage path on system. And :Z which mean are suffix,  this used for do auto relabel for those directory in SELinux in container_file_t context file type.

For this tutorial I’ll create podman container with named as mywebsite, port mapping from 8080 to 8900 and persistent storage path to ~/website.

$  podman run -d –name mywebsite -p 8900:8080 -v ~/website:/var/www/html:Z registry.redhat.io/rhel8/httpd-24:latest

Configure firewall-cmd so that the firewall system aware about port number 8900 used for web server.

$  sudo firewall-cmd –permanent –add-port=8900/tcp

$  sudo firewall-cmd –reload

Now test the configuration with cli using curl and through the web browser.

The configuration was successfull

z

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>