WordPress Docker Setup
A reusable Docker setup for deploying WordPress quickly and consistently. It spins up isolated WordPress environments for development, testing, or repeated project setups with minimal effort.
TOC
URL: https://github.com/hpetersen2/wordpress-docker-setup/
Checkout this repository to see the code/implementation
Description
The repository provides a ready-to-use Docker configuration that installs WordPress together with a database. Its purpose is to:
- Offer a simple, consistent, and repeatable WordPress setup
- Allow the configuration of multiple independent WordPress instances
- Reduce setup time by automating environment preparation
Contents of the repository:
docker-compose.yml— WordPress and database containers.env.template— Template with all configurable environment variables- Startup instructions for local development or server deployment
Features
- Quick WordPress deployment using Docker
- Fully configurable via
.env - Easily replicable for multiple projects
- Suitable for local development or server environments
- No manual database setup required
Quickstart
Prerequisites
- Docker installed
- Docker Compose v2+
- Git
Steps
-
Clone the repository
git clone https://github.com/HPetersen2/wordpress-docker-setup.gitcd wordpress-docker-setup -
Copy the environment file
cp .env.template .env -
Fill in the required values inside
.env, for example:WORDPRESS_DB_NAMEWORDPRESS_DB_USERWORDPRESS_DB_PASSWORDWORDPRESS_PORT
-
Start the containers
docker compose up -d -
Open WordPress in your browser (by default
http://localhost:8080, depending onWORDPRESS_PORT) and complete the installation wizard.
Usage
This section explains configuration options and how to manage the running setup.
Adjusting Configuration
All customizable values are located in the .env file.
WORDPRESS_DB_NAME=your_database
WORDPRESS_DB_USER=your_user
WORDPRESS_DB_PASSWORD=<choose-a-strong-password>
WORDPRESS_PORT=8080
WordPress is then available at http://localhost:<WORDPRESS_PORT>. After changing values, apply them with docker compose up -d.
To run multiple independent instances, clone the repository once per instance and use a different WORDPRESS_PORT for each.
Container Management
Stop containers:
docker compose down
View logs:
docker compose logs -f
Restart:
docker compose restart
docker compose down -v also removes the volumes and therefore deletes the database and all WordPress data. Use it only if you want to start from scratch.
Security Notes
- Never commit your
.envfile; it contains credentials. Only.env.templatebelongs in version control. - Use strong, unique database passwords.
- When deploying to a server, put WordPress behind a reverse proxy with HTTPS instead of exposing the port directly.