LAMP Server Setup Using Podman

Welcome to our Podman Lab, where you’ll engage in a dynamic, hands-on experience to master containerization using Podman. This lab offers a deep dive into setting up a LAMP stack with Podman, designed to build your skills in deploying and managing containerized applications. You’ll explore the essentials of Podman, configure your environment, orchestrate multi-container applications, and manage key components of the LAMP stack. By the end of this session, you’ll have a solid understanding of Podman’s capabilities and be well-prepared to utilize it effectively in various scenarios. Get ready to enhance your container management skills with this immersive lab experience!

Table of Contents

Objective

This lab aims to equip participants with practical skills in deploying and managing a LAMP stack using Podman. The focus is on understanding Podman’s fundamentals, installing and configuring the tool, orchestrating container deployment, and ensuring efficient container management. By the end of the lab, participants will be adept at using Podman for containerized applications, applying best practices in container orchestration, security, and performance optimization.

Learning Objectives

  1. Comprehend Podman Basics: Understand the core principles of Podman, including its architecture, functionalities, and advantages over traditional container tools like Docker.
  2. Setup and Configuration: Learn to install and configure Podman on various operating systems, setting up the environment for container management.
  3. Deploy a LAMP Stack with Podman: Acquire hands-on experience in deploying and managing the components of a LAMP stack (Linux, Apache, MySQL, PHP) in isolated containers using Podman.
  4. Container Networking and Storage: Master the techniques of networking containers for seamless intercommunication and implementing persistent storage solutions for data management within containers.
  5. Troubleshooting and Optimization: Develop skills in identifying and resolving common issues in a containerized environment and apply best practices to optimize container performance and security.

Technologies Used

  1. Podman: An open-source, daemonless container engine, used for developing, managing, and running OCI Containers on your Linux system.
  2. LAMP Stack Components:
    • Linux: The underlying operating system for containerization.
    • Apache: A popular web server software used in the stack.
    • MySQL: The relational database management system for data storage.
    • PHP: A server-side scripting language for web development.
  3. podman-compose: A tool for defining and running multi-container Podman applications, similar to Docker Compose.
  4. PHPMyAdmin: An optional tool for managing MySQL databases through a web interface.

These technologies combine to provide a comprehensive environment for learning containerization and application deployment using Podman.

Use Cases

The Podman Lab is designed for a variety of use cases, particularly in environments where containerization is key to development and deployment. Here are some specific scenarios where this lab would be highly applicable:

  1. Development and Testing: Developers can use the skills acquired from this lab to create isolated environments for developing and testing web applications, ensuring that the development environment mirrors the production setup.
  2. Educational Purposes: For students and educators in computer science or related fields, this lab offers practical experience in understanding and using container technologies, which are increasingly important in cloud computing and DevOps.
  3. Microservices Deployment: IT professionals can apply the knowledge to deploy and manage microservices architectures, where each service runs in a separate container for improved scalability and easier maintenance.
  4. Migration to Containerized Environments: Organizations looking to migrate from traditional monolithic architectures to containerized solutions can benefit from the hands-on experience in container management and orchestration.
  5. CI/CD Pipelines: Integrating Podman into Continuous Integration/Continuous Deployment (CI/CD) pipelines for automating the deployment of web applications in a more secure and efficient manner.
  6. Local Development Environments: Developers can replicate complex server architectures on their local machines for development and debugging purposes, without the overhead of virtual machines.
  7. Learning Best Practices: Understanding best practices in container orchestration, security, and performance, which is crucial for maintaining robust, efficient, and secure IT infrastructure.

In these scenarios, the Podman Lab serves as an invaluable resource for gaining practical experience and a deeper understanding of modern containerization technologies and practices.

Why This Matters

The Podman Lab is more than just a technical exercise; it holds significant relevance in today’s rapidly evolving IT landscape. Here’s why this matters:

  1. Growing Importance of Containerization: With the shift towards microservices and cloud-native development, containerization has become a cornerstone technology. Understanding and mastering tools like Podman is critical for IT professionals to stay relevant and effective.
  2. Daemonless and Secure: Podman’s daemonless architecture offers a more secure and simplified approach to container management, addressing some of the key concerns associated with traditional container engines like Docker.
  3. Compatibility with Docker: Podman is designed to be a drop-in replacement for Docker, making the skills learned in this lab highly transferable and valuable, especially as more organizations explore alternatives to Docker.
  4. Efficiency in Development and Deployment: Learning to deploy a LAMP stack using Podman streamlines the development process, enabling faster, more consistent, and repeatable deployments, a crucial aspect in modern DevOps practices.
  5. Resource Optimization: Podman’s lightweight nature and efficient resource usage make it an ideal choice for optimizing the performance of applications, especially in resource-constrained environments.
  6. Enhanced Learning for Various Roles: Whether you’re a developer, system administrator, or a DevOps engineer, understanding Podman equips you with the skills to design, deploy, and manage applications more effectively in a containerized environment.
  7. Future-Proofing Skills: As the industry continues to embrace containerization and cloud-native technologies, skills in Podman and similar tools ensure that professionals are well-prepared for future technological advancements and job requirements.

This lab offers not just technical knowledge, but also a strategic advantage in understanding and leveraging one of the key technologies shaping the future of software development and deployment.

What You Will Learn

In the Podman Lab, you will embark on a comprehensive learning journey to grasp the intricacies of containerization using Podman. Here’s a snapshot of the key skills and knowledge you will acquire:

  1. Podman Fundamentals: Understand the core principles and architecture of Podman, including its daemonless model and how it differs from other containerization tools.
  2. Installation and Setup: Learn how to install and configure Podman on different operating systems, setting up the foundation for container management.
  3. Container Management: Master the creation, management, and deployment of containers, gaining insights into Podman’s command-line interface and functionalities.
  4. LAMP Stack Deployment: Acquire hands-on experience in deploying a LAMP (Linux, Apache, MySQL, PHP) stack within Podman containers, understanding the role and setup of each component.
  5. Networking and Storage in Containers: Explore advanced aspects of container networking and persistent storage, essential for real-world applications.
  6. Security Best Practices: Gain knowledge of security practices related to containerization, including container isolation and image security.
  7. Troubleshooting and Debugging: Develop the ability to identify and resolve common issues that arise in a containerized environment.
  8. Optimization Techniques: Learn how to optimize container performance, resource usage, and scalability.
  9. Real-World Applications: Understand how to apply these skills in real-world scenarios, such as in development, testing, and deployment of applications.

By completing this lab, you will not only learn the technical aspects of using Podman but also how to apply this knowledge practically, making you proficient in managing and deploying containerized applications.

Real-World Application

The skills and knowledge gained from the Podman Lab have direct, impactful applications in various real-world scenarios:

  1. Microservices Architecture: Utilize Podman to deploy and manage microservices, enabling easier scaling and maintenance of applications.
  2. Development and Testing: Create consistent development environments that mirror production settings, enhancing software reliability and reducing deployment issues.
  3. Continuous Integration/Continuous Deployment (CI/CD): Integrate Podman into CI/CD pipelines for automated testing and deployment, streamlining the software development lifecycle.
  4. Cloud-native Development: Apply containerization concepts learned from Podman in cloud-native ecosystems, facilitating a smooth transition to cloud-based platforms.
  5. Efficient Resource Utilization: Leverage Podman’s efficient resource management for running applications on servers with limited resources, optimizing costs and performance.
  6. Enhanced Security: Implement Podman’s robust security features in environments where security and isolation of services are paramount.

This lab equips participants with the skills to effectively apply containerization concepts in these areas, demonstrating the versatility and practicality of Podman in modern IT environments.

Let’s Get Started!

Setting up a LAMP (Linux, Apache, MySQL, PHP) stack using Podman is similar to using Docker, but with some differences due to the way Podman handles containers and networking. Podman is daemonless and designed to be compatible with Docker, but it operates under a different security model and doesn’t require a running daemon.

Here’s a step-by-step guide to set up a LAMP stack using Podman:

  • SSH to the Rocky8 box
    • # ssh [username]@[ip address of box]
  • We are using Rocky8 for this Lab
    • # cat /etc/os-release
  • Verify Podman is installed if not install it
    • # podman –version
  • Looks like Podman is installed, if not follow the instructions here.
  • Create a directory for the project
    • # pwd – where are we in the file system
    • # ll – list the directory
    • # mkdir Projects && mkdir /Projects/lamp-podman && cd /Projects/lamp-podman
    • # pwd
  • Create a non-root user with root privileges, enable linger for the user
    • # useradd -c “Podman User” -G wheel poduser
    • # loginctl enable-linger poduser
  • Switch user to poduser, add the epel-release repo in order to install podman-compose then create the following file inside of the directory, ‘podman-compose.yml’.
    • # dnf config-manager –set-enabled powertools
    • # dnf install epel-release
    • # su – poduser
    • # sudo dnf install podman-compose -y
    • # podman-compose –version
    • # touch podman-compose.yml
  • Inside of the ‘podman-compose.yml’ file should look like this
    • # vim podman-compose.yml
    • Apache & PHP
      • Use an image that includes both Apache and PHP.
      • Map the default Apache port to a port on your host machine.
      • Mount a directory from your host to the container for the website file.
    • MySQL
      • Use the official MySQL image.
      • Define environment variables for the MySQL root password, database, user, and user password.
      • Optionally, mount a volume for persistent storage of MySQL data.
    • PHPMyAdmin
      • Use the official PHPMyAdmin image.
      • Link it to the MySQL container.
      • Map a port for PHPMyAdmin.
  • Create a ‘www’ directory in the project folder for the website files
    • # mkdir www
    • # ll
  • Start the containers. Run the following command in the same directory as your ‘podman-compose.yml’.
    • # podman-compose up -d
  • Accessing the servers.
    • Apache [ip address]:8000
    • PHPMyAdmin [ip address]:8080
  • Testing PHP
    • Create a ‘phpinfo.php’ file in the ‘www’ directory:
      • $ touch phpinfo.php
      • $ vim <?php phpinfo(); ?>
    • Visit [ip address]:8000/phpinfo.php
  • Check the containers running then shutdown the containers.
    • $ podman ps
    • $ podman-compose down

Summary

The Podman Lab provides a comprehensive, hands-on experience in containerization using Podman, a key tool in modern software development and deployment. Participants will learn the essentials of Podman, from installation and configuration to deploying a LAMP stack and managing containers. Key areas of focus include container management, networking, security, and optimization. This lab is designed to impart practical skills applicable in real-world scenarios like microservices architecture, CI/CD pipelines, cloud-native development, and more. By the end of the lab, participants will have a solid foundation in using Podman for efficient, secure, and scalable containerized applications.

Resources