Skip to main content

WordPress Docker Project

This repository contains a Docker Compose setup for running WordPress with a MySQL database.
The project is designed to be easy to deploy, with persistent data storage and configurable environment variables.

Table of Contents

Key Features

  • WordPress latest version in Docker
  • MySQL 8 database
  • Persistent volumes for WordPress files and database
  • Easy configuration via environment variables
  • Automatic container restart on failure

Quickstart

Prerequisites

  • Docker
  • Docker Compose

Steps

  1. Clone this repository:
git clone git@github.com:A-Marbach/wordpress.git
cd wordpress
  1. Copy the example environment file:
cp .env.example .env

Open .env and change the values if you want custom credentials.

Note: Do not commit .env to the repository; it contains sensitive information.

  1. Start the containers:
docker-compose up -d
  1. Open Wordpress in your browser:
http://<your_ip>:8080

Usage

  1. Open your browser and navigate to http://<your_ip>:8080 to complete the WordPress installation.
  • Create your WordPress admin user and password during the setup wizard.

Environment Variables

You have modify .env or the environment section in docker-compose.yaml for a secure deployment:

VariableDescriptionDefault
WORDPRESS_DB_NAMEDatabase name for WordPresswordpress
WORDPRESS_DB_USERWordPress DB useruser
WORDPRESS_DB_PASSWORDPassword for WordPress DB userpassword
MYSQL_ROOT_PASSWORDRoot password for MySQLrootpassword

Volumes

  • wordpress_data: stores WordPress files (themes, plugins, uploads)
  • db_data: stores MySQL database files

Volumes ensure data persists even after container restarts or recreation.

Restarting Containers

docker-compose restart

Stopping Containers

docker-compose down

Extras

You can install additional WordPress plugins by adding them to wp-content/plugins/

Custom themes can be added in wp-content/themes/

For debugging, view logs:

docker-compose logs wordpress
docker-compose logs db