Skip to main content
team-collaboration/version-control/githubGithub

WordPress with MariaDB Using Docker Compose

Welcome to your WordPress and MariaDB setup! This repository provides an easy-to-use configuration for hosting a WordPress website backed by a MariaDB database using Docker Compose.

Table of Contents

  1. Description
  2. Quickstart
  3. Usage

Description

This repository includes a Docker Compose setup for quickly launching a WordPress instance with a MariaDB database. It simplifies the process of setting up and maintaining a WordPress site with an underlying database.

Key features:

  • Containerized Deployment: Run WordPress and MariaDB reliably using Docker.
  • Environment Variable Configuration: Easily customize credentials and database details via a .env file.
  • Scalable & Portable: Run locally or deploy on a remote server/VM.

Quickstart

Prerequisites

Ensure you have the following tools installed:

  • Docker
    • Docker Compose was included with Docker versions 20.10 and later, but recently it is no longer included by default. For the latest Docker versions, you will need to install Docker Compose manually as a plugin. Follow the official instructions for detailed steps.
  1. Clone this repository:

    git clone https://github.com/PascalNehlsen/wordpress-container
    cd wordpress-container
  2. Create a .env file from the example configuration:

    cp example.env .env
  3. Edit the .env file to set your desired configuration (see Configuration).

  4. Start the WordPress and MariaDB containers:

    docker compose up -d
  5. Access your WordPress site:

    • Open your browser and navigate to http://localhost:8080 (or your server's IP if running remotely).
    • Now you can configure the Admin panel.
  6. To stop the server, use:

    docker compose down

Usage

Configuration

The example.env file allows you to customize the WordPress and MariaDB setup. Below is a list of the environment variables and their functions:

VariableDescriptionPossible ValuesRequired
WORDPRESS_USERUsername for the WordPress admin account.userYes
WORDPRESS_PASSWORDPassword for the WordPress admin account.passwordYes
DATABASE_NAMEName of the MariaDB database used by WordPress.wordpressYes
DATABASE_HOSTHostname of the database (matches the db service) and db exposed Port.db:3306Yes

Updating the Setup

To modify the configuration, edit the .env file and restart the containers:

docker compose down
docker compose up -d