Close
  • Home
  • About
  • Services
ukr
  • Projects
  • Blogs
  • Contact
  • Menu

Setting Up a Powerful Development Environment with Docker Compose for Apache, MariaDB, and phpMyAdmin

By Ujjal Ray on 1 January 2024 • 10 min read
Scroll

Introduction:

In today's fast-paced development environment, having a reliable and easily reproducible setup is crucial. Docker Compose simplifies the process of orchestrating multiple containers, making it easier to manage and deploy complex applications. In this blog post, we'll guide you through creating a Docker Compose file for a robust development environment consisting of Apache, MariaDB, and phpMyAdmin.

Docker Compose File Overview: Let's break down the Docker Compose file provided above and understand each service's role:

  1. Apache Service:

    • Built from a Dockerfile in the current context.
    • Container name: apache.
    • Maps host port 80 to container port 80.
    • Mounts local directories for website content (./htdocs), Apache configuration (./000-default.conf), and PHP settings (./uploads.ini).
    • Memory limit: 8GB, 2 CPUs.
    • Depends on the "db" service.
    • Connected to the "xampp-network."
  2. MariaDB Service (db):

    • Uses the latest MariaDB image.
    • Container name: db.
    • Maps host port 3306 to container port 3306.
    • Loads environment variables from the .env file.
    • Mounts a local directory for MariaDB data (./mysql_data).
    • Memory limit: 8GB, 2 CPUs.
    • Connected to the "xampp-network."
  3. phpMyAdmin Service:

    • Uses the latest phpMyAdmin image.
    • Container name: phpmyadmin.
    • Links to the "db" service.
    • Sets up phpMyAdmin environment variables, including host, port, user, and password.
    • Memory limit: 8GB, 2 CPUs.
    • Maps host port 8080 to container port 80.
    • Connected to the "xampp-network."
  4. Networks and Volumes:

    • Defines a custom bridge network named "xampp-network."
    • Creates volumes for MariaDB data (mysql_data) and Apache website content (htdocs).

Conclusion: With this Docker Compose configuration, you can easily spin up a development environment with Apache, MariaDB, and phpMyAdmin. The defined services are interconnected through a custom network, ensuring seamless communication. The use of volumes allows persistent storage for databases and web content, while resource limits ensure efficient resource utilization.

To use this setup, save the provided Docker Compose file to your project directory and run docker-compose up -d to start the services in the background. Access your web application at http://localhost and phpMyAdmin at http://localhost:8080, with the flexibility to customize configurations based on your project requirements. Happy coding!

 

Github Repo: https://github.com/RayUjjal/Docker_Xampp.git

ukr