Linux Apache Mariadb PhP using Podman

Table of Contents

How to containerize PHP and MariaDB Using Podman:

Step 1: Create Containerfile and add this data:

FROM registry.access.redhat.com/ubi8/ubi-init

#FROM registry.fedoraproject.org/fedora:34

MAINTAINER nevyanmail@yahoo.com

RUN yum install -y php php-apcu php-intl php-mbstring php-xml php-json php-mysqlnd crontabs cronie iputils net-tools; yum clean all

RUN systemctl enable httpd.service

ENTRYPOINT ["/sbin/init"]

CMD ["/sbin/init"]

Step 2: Build image:

In same directory:

$ podman build -t localhost:5000/httpd-php:1.0 .

Step 3: Create pod for your containers:

Create a pod:

$ podman pod create --name my-web-pod -p 8080:80

List all the pods:

$ podman ps -a --pod

Step 4: Add php container to my-web-pod:

$ podman run -d --read-only --rm --pod my-web-pod -v /var/www/html/:/var/www/html/:Z --tmpfs /var/log --tmpfs /var/tmp --name mydevcontainer localhost:5000/httpd-php:1.0

Step 5: Add mariadb database container to my-web-pod:

$ podman run -d --rm --pod my-web-pod --name mariadb_database -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db MYSQL_ROOT_PASSWORD=pass mariadb

If you are not using Podman Desktop (You should), from Podman Desktop Dashboard you can start your pod.

Thank you for going through this post, Have a nice one!

Tags :