This project sets up a WordPress web-instance using Docker Compose with three main services:
- Image:
wordpress:latest - Port: Exposed via Caddy
- Volumes: Persists WordPress content in the
wordpressvolume - Environment:
- Reads database credentials from
.env
- Reads database credentials from
- Networks:
frontend: connects to Caddybackend: connects to MySQL
- Image:
caddy:2.10 - Port Mapping:
443 → 8081on host (access viahttps://wp.local:8081) - TLS: Uses
tls internalor Let's Encrypt depending on configuration - Config:
- Loaded from a generated
Caddyfilein theconf/directory
- Loaded from a generated
- Features:
- Automatic HTTPS (for real domains) or internal TLS for development
- Gzip compression
- Volumes:
- Persists TLS and configuration data via
caddy_dataandcaddy_config
- Persists TLS and configuration data via
- Security:
- Runs as read-only
- Uses
tmpfsfor temporary and cert-related directories - Requires
NET_ADMINcapability (needed for Caddy’s network config)
- Image:
mysql:5.7 - Volumes: Data persisted in
db_data - Environment:
- Fully controlled via
.env(e.g., DB name, user, root password)
- Fully controlled via
- Networks:
backend: communicates only with WordPress
Before running the stack, create a .env file in the root directory with:
HOSTNAME=wp.local
EMAIL=[email protected]
DB_NAME=wordpress
DB_USER=wordpress
DB_PASSWORD=your_db_password
DB_ROOT_PASSWORD=your_root_passwordTo start the services, run:
./run.shThe caddyfile needs to be rendered with the .env variables, which is done in the run.sh script.
User Login URL: https://<hostname>/wp-login.php