WordPress with Docker – Jumpstart
Here’s a straightforward docker-compose setup for running WordPress locally with persistent data, mapped plugins directory, and custom PHP upload settings. I use it as a Dev environnement but should work for prod with minor changes.
The Configuration
Create a new directory and the following “docker-compose.yaml”
---
services:
db:
container_name: 'wordpress-db'
image: 'mysql:8.0'
volumes:
- './data/mysql:/var/lib/mysql'
environment:
MYSQL_ROOT_PASSWORD: CHANGEME_SQL_PASSWORD_CHANGEME
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress_password
www:
container_name: 'wordpress-www'
depends_on:
- db
image: 'wordpress:latest'
ports:
- 8888:80
environment:
WORDPRESS_DB_HOST: 'db:3306'
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: CHANGEME_SQL_PASSWORD_CHANGEME
WORDPRESS_DB_NAME: wordpress
volumes:
- "./wordpress:/var/www/html"
- "./plugins:/var/www/html/wp-content/plugins"
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
And here is my uploads.ini file for reference, this is probably too much for production, tune accordingly.
file_uploads = On
memory_limit = 500M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 600
Key Features
This setup provides:
– MySQL 8.0 database with persistent storage
– Latest WordPress container with mapped directories
– Custom PHP upload settings via uploads.ini
– Exposed ports for direct database access (18766) and web access (6680)
Usage
Start the stack with:
$ docker-compose up -d
or
$ docker-compose up --pull always -d # To force pulling the images.
Access WordPress at http://localhost:8888 and complete the installation. Your database will be preserved in ./data/mysql, and you can manage plugins directly through the ./plugins directory.
Enjoy !