- Project Description
- Quickstart
- Usage
- Healthchecks
- Testing and Troubleshooting
- Security Considerations
This repository contains a Docker Compose setup for running a WordPress instance alongside a MySQL (MariaDB) database. The goal is to simplify the deployment of a WordPress development environment using Docker. It includes pre-configured services for WordPress and MySQL, health checks, and persistent storage for both services.
Ensure you have the following installed:
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/henrymanke/wordocker.git cd wordocker -
Set up environment variables by creating a
.envfile:cp example.env .env
-
Start the services using Docker Compose:
docker compose up -d
-
Open your browser and access WordPress:
- Go to
http://localhost:8080or the port configured in the.envfile.
- Go to
To tailor the setup to your needs, modify the following environment variables in the .env file:
# MySQL Database Configuration
MYSQL_ROOT_PASSWORD=<your_root_password> # The root password for MySQL.
MYSQL_DATABASE=<your_db_name> # The MySQL database name.
MYSQL_USER=<your_db_user> # The MySQL user.
MYSQL_PASSWORD=<your_db_user_password> # The MySQL user password.
# WordPress Configuration
WORDPRESS_PORT=<your_port> # The port where WordPress will be accessible.
WORDPRESS_TABLE_PREFIX=<your_prefix> # The table prefix for WordPress.
# Version Control
MARIADB_VERSION=10.5 # Optional: Set a specific version for MariaDB
WORDPRESS_VERSION=5.7 # Optional: Set a specific version for WordPress
After making any changes, restart the services:
docker compose down
docker compose up -dOR
docker compose restart <service>- MySQL Data: Stored in a volume
db_data. - WordPress Data: Stored in a volume
wordpress_data.
This setup ensures your data persists even after restarting or stopping the containers.
- MySQL Healthcheck: Monitors if MySQL is up and running using the following command:
healthcheck.sh --connect --innodb_initialized
- WordPress Healthcheck: Validates that WordPress is responding correctly:
curl -f http://localhost:${WORDPRESS_PORT} || exit 1
If any service fails the health check, Docker will restart the container.
Before submitting or deploying, ensure the following:
- WordPress is accessible at
http://localhost:${WORDPRESS_PORT}. - You can log in with your admin credentials and navigate through WordPress.
- After restarting the setup, all your data remains intact.
- To inspect logs:
docker compose logs
- If a container crashes, it will automatically restart due to the
restart: alwayspolicy.
- Environment Variables: Avoid storing sensitive information such as SSH keys, passwords, or IP addresses directly in the repository. Use environment variables via
.envfiles. - Naming Conventions: For environment variables, use the
UPPER_CASE_WITH_UNDERSCOREformat. Reference them using${VARIABLE_NAME}to avoid errors in shell scripts.
- Ensure that all default values are sensible and secure.
- Regularly review Docker and WordPress security practices to keep your setup safe from vulnerabilities.