A simple and efficient way to set up a WordPress environment using Docker Compose. This repository provides a fully customizable and ready-to-use WordPress stack.
- WordPress with MariaDB as the database
- Support for multi-environment setups (development, staging, production)
- Automatic SSL with Let's Encrypt (optional)
- Preconfigured themes and plugins (optional)
- WP-CLI support for managing WordPress via the command line
- Health checks for WordPress and database services
Make sure you have the following installed:
git clone https://github.com/YOUR_USERNAME/wordpress-docker-compose.git
cd wordpress-docker-compose
Copy the .env.example
file and update the variables as needed:
cp .env.example .env
Key variables include:
WORDPRESS_DB_USER
: Database usernameWORDPRESS_DB_PASSWORD
: Database passwordWORDPRESS_DB_NAME
: Database nameWORDPRESS_TABLE_PREFIX
: Table prefix for WordPress
Run the following command to start WordPress and MariaDB:
docker-compose up -d
Visit http://localhost:8000
in your browser.
wordpress-docker-compose/
├── docker-compose.yml # Main Docker Compose configuration
├── wp-content/ # WordPress content directory for themes, plugins, and uploads
├── .env.example # Example environment variables
├── ssl/ # Directory for SSL certificates (optional)
└── README.md # Documentation
To use different configurations for development, staging, and production, create separate .env
files for each environment (e.g., .env.dev
, .env.prod
). Then run:
docker-compose --env-file .env.dev up -d
Modify the docker-compose.yml
file to include commands for downloading themes and plugins. For example:
services:
wordpress:
volumes:
- ./themes:/var/www/html/wp-content/themes
- ./plugins:/var/www/html/wp-content/plugins
Place your theme files in the themes/
directory and plugin files in the plugins/
directory.
To use WP-CLI, run the following command:
docker-compose exec wordpress wp <command>
Example:
docker-compose exec wordpress wp plugin install jetpack
To enable SSL with Let's Encrypt:
- Add a new service to
docker-compose.yml
for SSL management. - Use the certbot Docker image to generate SSL certificates.
- Update the Nginx configuration to use these certificates.
Add health checks to ensure WordPress and MariaDB are running properly. For example:
services:
wordpress:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000"]
interval: 30s
timeout: 10s
retries: 3
We welcome contributions! To contribute:
- Fork the repository.
- Create a new branch for your feature.
- Commit your changes.
- Open a pull request.
This project is licensed under the MIT License.