Docker Orchestration
Docker Orchestration
To ensure a consistent development environment across the team, this project utilizes Docker and Docker Compose. This containerization strategy encapsulates the WordPress core, the database, and any necessary server configurations, eliminating the "it works on my machine" syndrome.
Prerequisites
Before starting, ensure you have the following installed on your host machine:
- Docker Desktop (macOS or Windows) or Docker Engine (Linux).
- Docker Compose (included with Docker Desktop).
Quick Start
To spin up the entire WordPress stack, navigate to the root directory of the repository and run:
docker-compose up -d
This command will:
- Pull the required images (WordPress and MySQL/MariaDB).
- Configure the internal network.
- Mount local volumes for persistent data.
- Expose the WordPress site at
http://localhost:8080.
To stop the environment without deleting data:
docker-compose stop
Environment Configuration
The orchestration relies on an .env file located in the root directory. This file defines the credentials and versions used by the containers.
| Variable | Description | Default Value |
| :--- | :--- | :--- |
| WORDPRESS_DB_HOST | The service name or IP of the database container. | db |
| WORDPRESS_DB_USER | Username for the database connection. | exampleuser |
| WORDPRESS_DB_PASSWORD | Password for the database connection. | examplepass |
| WORDPRESS_DB_NAME | The name of the WordPress database. | wordpress |
| WP_PORT | The host port where WordPress is accessible. | 8080 |
Services Architecture
The docker-compose.yml file defines two primary services intended for public interaction:
1. wordpress
The application container running the PHP-FPM and Apache/Nginx environment.
- Exposed Port:
8080(Default) - Volumes: Maps
./wp-contentto/var/www/html/wp-contentto allow for real-time theme and plugin development.
2. db
The relational database engine.
- Image:
mysql:5.7ormariadb:latest. - Persistence: Data is stored in a named Docker volume (
db_data) to ensure database state is preserved even if containers are removed.
Common Operations
Accessing Logs
To view the real-time output from the WordPress and Database containers:
docker-compose logs -f
Running WP-CLI
You can execute WP-CLI commands directly within the running container without installing the tool locally:
docker-compose exec wordpress wp plugin list
Resetting the Environment
To completely remove the containers and the database volumes (warning: this deletes all site data):
docker-compose down -v
Internal Utility Scripts (Internal Only)
The repository may contain an internal bin/setup-docker.sh script. While this is used by the maintainers to automate initial image layering, users should stick to the standard docker-compose commands listed above for daily development tasks.