A production-ready Docker template for WordPress using MariaDB.
- WordPress (latest)
- MariaDB (latest)
-
Copy the example env file and fill in your values:
cp .env.example .env
-
Start the containers:
docker compose up -d
-
Open http://localhost:8080 to complete the WordPress setup.
| Variable | Description |
|---|---|
MARIADB_ROOT_PASSWORD |
MariaDB root password |
MARIADB_DATABASE |
Database name |
MARIADB_USER |
Database user |
MARIADB_PASSWORD |
Database password |
├── docker-compose.yml
├── php.ini # Custom PHP configuration
└── wp-content/
├── mu-plugins/
├── plugins/
├── themes/
└── uploads/
phpMyAdmin is included but gated behind the tools profile so it never starts automatically.
# Start phpMyAdmin alongside the normal stack
docker compose --profile tools up -d
# Or start it on its own (db must already be running)
docker compose --profile tools up -d phpmyadmin
# Stop everything including phpMyAdmin
docker compose --profile tools downOnce running, open http://localhost:8081 and log in with your MARIADB_USER / MARIADB_PASSWORD credentials (or root).
Never expose port 8081 publicly in production.
The WordPress image ships with WP-CLI. Run commands via docker compose exec:
docker compose exec wordpress wp --info# Install and activate a plugin
docker compose exec wordpress wp plugin install woocommerce --activate
# Search-replace a URL (useful after cloning a DB)
docker compose exec wordpress wp search-replace 'https://old.example.com' 'https://new.example.com'
# Export the database
docker compose exec wordpress wp db export - > backup.sql
# Import a database dump
docker compose exec wordpress wp db import - < backup.sql
# Flush the cache
docker compose exec wordpress wp cache flush
# Create an admin user
docker compose exec wordpress wp user create admin admin@example.com --role=administrator --user_pass=secretWP-CLI runs as
www-datainside the container, so it has the same filesystem permissions as WordPress itself.
# Start
docker compose up -d
# Stop
docker compose down
# View logs
docker compose logs -f