How to Self-Host WordPress with Docker and InfraPilot
InfraPilot Team
March 4, 2026
Why Self-Host WordPress?
Managed WordPress hosting is expensive for what it is: a single PHP application and a MySQL database. Kinsta, WP Engine, and Pressable charge $25–50/mo for what amounts to two containers and an Nginx config. Running WordPress yourself on a $6/mo VPS — with InfraPilot managing your reverse proxy, SSL, and monitoring — costs a fraction of that.
Prerequisites
- A Linux VPS with Docker installed (
curl -fsSL https://get.docker.com | sh) - A domain name with an A record pointing at your server IP
- InfraPilot running — install with
curl -fsSL https://infrapilot.org/install.sh | bash
Step 1 — Create the Compose File
Create a directory for your WordPress site and add a docker-compose.yml:
mkdir -p ~/apps/wordpress && cd ~/apps/wordpress
services:
db:
image: mysql:8.0
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
- db_data:/var/lib/mysql
wordpress:
image: wordpress:6-php8.2-fpm-alpine
restart: unless-stopped
depends_on:
- db
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
WORDPRESS_TABLE_PREFIX: wp_
volumes:
- wp_data:/var/www/html
ports:
- "9000:9000"
volumes:
db_data:
wp_data:
Create a .env file with strong passwords:
DB_ROOT_PASSWORD=change-me-root-password
DB_PASSWORD=change-me-wp-password
Start the stack:
docker compose up -d
Step 2 — Add a Reverse Proxy in InfraPilot
WordPress FPM doesn't serve HTTP directly — you need Nginx in front. InfraPilot handles this for you:
- Open the InfraPilot dashboard → Traffic → Proxy Hosts → Add Proxy Host
- Set the domain to your WordPress domain (e.g.
myblog.com) - Set the forward host to
wordpressand port to9000 - Enable SSL → Let's Encrypt and tick Force SSL
- Save — InfraPilot provisions the certificate and configures Nginx automatically
Step 3 — Run the WordPress Setup Wizard
Navigate to your domain — you'll see the WordPress installation screen. Choose your language, set your site title, and create your admin account. Your site is live with HTTPS in under 5 minutes.
Step 4 — Monitor WordPress with InfraPilot
Back in the InfraPilot dashboard, you can see real-time CPU and memory usage for both the wordpress and db containers. Set up an alert under Security → Alerts to notify you if either container crashes or if memory usage exceeds 80%.
The unified log view streams both WordPress error logs and Nginx access logs in one place — no SSH required to debug a 500 error or a slow query.
Keeping WordPress Updated
To update to the latest WordPress image, pull and restart from the InfraPilot dashboard or run:
docker compose pull && docker compose up -d
InfraPilot's self-update feature also keeps your monitoring layer current — check for updates under Settings → General → Software Update.
Related posts
Secrets in Self-Hosted Docker: Stop Committing .env Files
The .env file works until it leaks, drifts, or gets committed by accident. Here is what moving to an encrypted secrets store with versioning and container binding actually changes, and how to migrate without code changes.
Preview Environments for Every Branch, on Your Own Box
Reviewing a diff only gets you so far. Preview environments give every branch a live URL on your own servers, with wildcard SSL and automatic teardown, so reviewers click instead of imagine.
Running Docker Across Three Servers Without Kubernetes
One server is easy and Kubernetes is a lot. Fleet is the middle path: run Docker across several servers with a scheduler, replicas, self-healing, and a private mesh, and no cluster to operate.