Back to Blog
wordpressdockerself-hostingtutorial

How to Self-Host WordPress with Docker and InfraPilot

I

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:

  1. Open the InfraPilot dashboard → Traffic → Proxy Hosts → Add Proxy Host
  2. Set the domain to your WordPress domain (e.g. myblog.com)
  3. Set the forward host to wordpress and port to 9000
  4. Enable SSL → Let's Encrypt and tick Force SSL
  5. 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.