Write down Docker Compose file for Joomla application

Write down Docker Compose file for Joomla application

To make a Docker Compose file for a Joomla app, you need to set up services for Joomla and a database (like MySQL). Here's a simple example of a Docker Compose file for a Joomla app:

version: '3'

    image: joomla:latest
      - "8080:80"
      - JOOMLA_DB_HOST=db
      - JOOMLA_DB_USER=root
      - JOOMLA_DB_PASSWORD=rootpassword
      - JOOMLA_DB_NAME=joomla
      - db
      - joomla_data:/var/www/html

    image: mysql:5.7
      - MYSQL_ROOT_PASSWORD=rootpassword
      - MYSQL_DATABASE=joomla
      - MYSQL_USER=joomla
      - MYSQL_PASSWORD=joomlapassword
      - db_data:/var/lib/mysql



  • The joomla service uses the official Joomla image from Docker Hub. It shows the Joomla web app on port 8080 and creates environment variables to connect to the MySQL database.

  • The db service uses the official MySQL 5.7 image. It creates environment variables to set up the MySQL database.

  • Both services use volumes to persist data:

    • joomla_data volume is mounted to the Joomla container to persist Joomla application data.

    • db_data volume is mounted to the MySQL container to persist MySQL data.

  • depends_on is used to ensure that the db service (MySQL) starts before the joomla service (Joomla) starts.

To use this Docker Compose file:

  1. Create a file named docker-compose.yml and copy the content above into it.

  2. Run the following command in the same directory as your docker-compose.yml file:

     docker-compose up

This will download the necessary Docker images, create and start containers for Joomla and MySQL, and expose Joomla on http://localhost:8080.

Once you've set this up, go to http://localhost:8080 in your web browser to access the Joomla installation wizard. Follow the steps on the screen to finish installing Joomla. Remember to enter the MySQL database connection details from the Docker Compose file.

Did you find this article valuable?

Support LingarajTechhub All About Programming by becoming a sponsor. Any amount is appreciated!