This repository provides a ready-to-run Docker setup for WordPress theme development. It provisions Nginx, PHP-FPM (based on the official WordPress image), MySQL, and WP-CLI so you can focus on building your theme instead of wiring up infrastructure.
- Docker Engine 24+ and the Docker Compose plugin (
docker composecommand) - Make sure you can allocate at least 2 GB of RAM to Docker Desktop (if applicable)
-
Copy the environment file and tweak values as needed:
cp .env.example .env
The defaults expose WordPress at
http://localhost:8080while internally using the host namewordpress.local. Update the credentials or host/port if they conflict with other projects. -
(Optional) Add the host name to your system’s
hostsfile if you plan to usewordpress.local:127.0.0.1 wordpress.localYou can skip this step and simply browse to
http://localhost:8080if you prefer. -
Build the images and start the stack:
docker-compose up -d --build
-
Complete the WordPress installation wizard at your chosen URL (default
http://localhost:8080). Use the database credentials defined in.env; the stack already created the database so you can click through without changing them. -
Activate the included starter theme:
- Browse to
Appearance → Themes - Locate WordPress Theme Base and click Activate
- Browse to
The theme/ directory is mounted into the container at wp-content/themes/${THEME_SLUG} (defaults to theme-base), so any changes you make locally are reflected immediately.
| Service | Image | Ports | Notes |
|---|---|---|---|
mysql |
mysql:8.0 |
not exposed externally | Data persisted in the mysql_data volume |
wordpress |
wordpress:6.4.3-php8.2-fpm |
— | Runs PHP-FPM and bundles WP-CLI |
nginx |
nginx:1.25-alpine |
${HOST_HTTP_PORT}:80 |
Serves WordPress via PHP-FPM |
The WordPress and Nginx services share a named volume (wordpress_data) for the WordPress core files while mounting your theme from the repository.
WP-CLI is preinstalled in the PHP-FPM container. Run one-off commands like so:
docker compose run --rm wordpress wp core version
docker compose run --rm wordpress wp plugin listBecause the theme directory is mounted, WP-CLI commands that interact with themes/plugins operate on your local files.
- Theme slug: Update
THEME_SLUGin.envif you rename thetheme/directory. WordPress expects the folder name and the theme header (Text Domain) to match for translations. - Debugging:
WP_DEBUGdefaults totrue. Switch it tofalsein.envfor production-like testing. - PHP configuration: Adjust limits (memory, uploads, execution time) in
docker/php/uploads.ini. - Database access: Use any MySQL client with the credentials in
.env. Since the database is not published outside the Docker network, connect via another container,docker compose exec mysql mysql -u wordpress -p, or expose the port temporarily by editingdocker-compose.yml.
- View logs:
docker compose logs -f nginx docker compose logs -f wordpress
- Stop services without removing data:
docker compose down
- Stop services and remove volumes (including database content):
docker compose down --volumes
.
├── docker-compose.yml # Docker stack definition
├── docker/
│ ├── nginx/
│ │ └── default.conf # Nginx virtual host configuration
│ └── php/
│ ├── Dockerfile # Extends the WordPress FPM image with WP-CLI
│ └── uploads.ini # PHP overrides
├── theme/
│ ├── functions.php # Theme bootstrap
│ ├── index.php # Basic template placeholder
│ └── style.css # Theme metadata + global styles
├── .env.example # Sample environment variables
└── README.md # This file
Modify or expand the theme files to suit your project. Add build tools (Webpack, Vite, etc.) as needed—Docker does not impose any restrictions on your Node/asset pipeline.