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.
- 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
- Docker
- Docker Compose
- Clone this repository:
git clone git@github.com:A-Marbach/wordpress.git
cd wordpress- Copy the example environment file:
cp .env.example .envOpen .env and change the values if you want custom credentials.
Note: Do not commit .env to the repository; it contains sensitive information.
- Start the containers:
docker-compose up -d- Open Wordpress in your browser:
http://<your_ip>:8080
- 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.
You have modify .env or the environment section in docker-compose.yaml for a secure deployment:
| Variable | Description | Default |
|---|---|---|
| WORDPRESS_DB_NAME | Database name for WordPress | wordpress |
| WORDPRESS_DB_USER | WordPress DB user | user |
| WORDPRESS_DB_PASSWORD | Password for WordPress DB user | password |
| MYSQL_ROOT_PASSWORD | Root password for MySQL | rootpassword |
- 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 restartStopping Containers
docker-compose downYou 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