Self-Host a Dynamic Website Using WordPress at Home with Docker

Self-Host a Dynamic Website Using WordPress at Home with Docker
Photo by Deng Xiang / Unsplash

If you have ever wanted to run your own dynamic website, blog, or portfolio without relying on third-party hosting providers, self-hosting WordPress at home is a great solution. With Docker, you can quickly deploy WordPress and its database in isolated containers, making setup and management much easier. This tutorial will guide you step by step on how to set up WordPress at home using Docker.


Why Self-Host WordPress at Home?

  • Full control over your data and website.
  • Low cost since you don’t have to pay for expensive hosting.
  • Learning experience for Docker, Linux, and networking.
  • Flexibility to customize everything – themes, plugins, and even server configuration.

Prerequisites

Before we start, make sure you have:

  • A home server, Mini PC, or Raspberry Pi (with at least 2GB RAM recommended).
  • Ubuntu 22.04/24.04 Server or another Linux distro installed.
  • Docker & Docker Compose installed.
  • A domain name (optional but recommended for public access).
  • Router access to configure port forwarding if hosting publicly.

Step 1: Install Docker & Docker Compose

First, update your system and install Docker:

sudo apt update && sudo apt upgrade -y
sudo apt install docker.io docker-compose -y
sudo systemctl enable docker --now

Verify installation:

docker --version
docker-compose --version


Step 2: Create a Docker Compose File

Create a project folder for WordPress:

mkdir ~/wordpress && cd ~/wordpress
nano docker-compose.yml

Paste the following configuration:

version: '3.9'

services:
wordpress:
image: wordpress:latest
container_name: wordpress
restart: always
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wpuser
WORDPRESS_DB_PASSWORD: wppassword
WORDPRESS_DB_NAME: wordpress
volumes:
- wordpress_data:/var/www/html

db:
image: mysql:5.7
container_name: wordpress_db
restart: always
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: wpuser
MYSQL_PASSWORD: wppassword
MYSQL_ROOT_PASSWORD: rootpassword
volumes:
- db_data:/var/lib/mysql

volumes:
wordpress_data:
db_data:

This configuration runs two containers:

  • WordPress – The website itself.
  • MySQL – The database to store your site content.

Step 3: Start Your Containers

Run the following command:

docker-compose up -d

Check if containers are running:

docker ps

Now, open your browser and go to:

http://localhost:8080

You should see the WordPress installation screen. 🎉


Step 4: Configure WordPress

  1. Choose your language.
  2. Enter your site title, admin username, password, and email.
  3. Log in to your WordPress dashboard.

From here, you can install themes, plugins, and start creating posts.


Step 5: Access WordPress from the Internet

If you want your site to be publicly accessible:

  1. Port Forwarding: Log into your router and forward port 80 (and 443 if using SSL) to your home server’s IP.
  2. Domain Name: Point your domain DNS to your public IP.
  3. SSL/HTTPS: Use NGINX Proxy Manager or Let’s Encrypt with Docker to secure your site.

Deploying NGINX Proxy Manager in Your Homelab with Docker Compose on Ubuntu Server
Introduction Managing multiple internal applications and websites within a homelab can quickly become a headache—especially when handling reverse proxies and SSL certificates manually. NGINX Proxy Manager (NPM) simplifies this process with an intuitive web UI, letting you create proxy hosts, manage SSL via Let’s Encrypt, and configure access control

Step 6: Manage Your WordPress Server

  • To stop containers:docker-compose down
  • To update WordPress:docker-compose pull
    docker-compose up -d
  • To view logs:docker logs wordpress

Conclusion

By following these steps, you’ve successfully self-hosted a dynamic WordPress website using Docker right from your home. This setup gives you complete control over your content, saves you hosting fees, and allows you to learn more about containers and server management.

Whether you’re running a personal blog, a family website, or experimenting with web development, self-hosting WordPress with Docker is a fun and rewarding project.


Thank you so much for taking the time to read my blog! Your support and engagement truly mean a lot and inspire me to keep creating and sharing more valuable content. If you enjoyed this post, I’d love to hear your thoughts—feel free to leave a comment in the box below and join the conversation. And if you’d like to stay updated with the latest posts, tips, and insights, don’t forget to subscribe to my newsletter. By joining, you’ll be the first to know when new content is published, so you never miss an update.