Skip to Content

WordPress and Docker: Local Development Environment

Reproducible environment in three minutes

Every time you set up a WordPress development environment manually, you waste time installing PHP, MySQL, configuring virtual hosts, and debugging version conflicts. Docker eliminates all of that.

docker-compose.yml

One file. Three services: WordPress (official Docker image), MariaDB, and phpMyAdmin if you want it. docker compose up -d and the environment is running. Same PHP version, same database version, every time.

Volumes

Mount wp-content as a local volume. You edit themes and plugins locally with your regular editor; changes appear instantly in the container. The database is stored in a named volume so it survives container restarts.

Why not MAMP/XAMPP?

MAMP and XAMPP work but give you one environment. With Docker you can have three projects running simultaneously with different PHP versions. Project A runs PHP 8.2, project B runs 8.1 to match the client's server. No conflict.

Production parity

The Docker image can match your production environment exactly. Same PHP extensions, same configuration. "It worked on my machine" stops being a problem.

Practical

Clone the repo, run docker compose up -d, import a database dump, done. A new developer on the team can have the environment running in three minutes instead of half a day. It makes onboarding a non-issue.

The only downside: Docker requires some disk space (each image is 500 MB to 1 GB) and RAM. But on a modern development machine, that's rarely a problem.

Custom Post Types: Build Your Own with Code
More than posts and pages