Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

2 Commits

Repository files navigation

wp-docker

A production-ready Docker template for WordPress using MariaDB.

Stack

  • WordPress (latest)
  • MariaDB (latest)

Getting Started

  1. Copy the example env file and fill in your values:

    cp .env.example .env
  2. Start the containers:

    docker compose up -d
  3. Open http://localhost:8080 to complete the WordPress setup.

Environment Variables

VariableDescription
MARIADB_ROOT_PASSWORDMariaDB root password
MARIADB_DATABASEDatabase name
MARIADB_USERDatabase user
MARIADB_PASSWORDDatabase password

Project Structure

├── docker-compose.yml
├── php.ini # Custom PHP configuration
└── wp-content/
├── mu-plugins/
├── plugins/
├── themes/
└── uploads/

phpMyAdmin

phpMyAdmin is included but gated behind the tools profile so it never starts automatically.

# Start phpMyAdmin alongside the normal stack
docker compose --profile tools up -d
# Or start it on its own (db must already be running)
docker compose --profile tools up -d phpmyadmin
# Stop everything including phpMyAdmin
docker compose --profile tools down

Once running, open http://localhost:8081 and log in with your MARIADB_USER / MARIADB_PASSWORD credentials (or root).

Never expose port 8081 publicly in production.

WP-CLI

The WordPress image ships with WP-CLI. Run commands via docker compose exec:

docker compose exec wordpress wp --info

Common examples

# Install and activate a plugin
docker compose exec wordpress wp plugin install woocommerce --activate
# Search-replace a URL (useful after cloning a DB)
docker compose exec wordpress wp search-replace 'https://old.example.com''https://new.example.com'# Export the database
docker compose exec wordpress wp db export - > backup.sql
# Import a database dump
docker compose exec wordpress wp db import - < backup.sql
# Flush the cache
docker compose exec wordpress wp cache flush
# Create an admin user
docker compose exec wordpress wp user create admin admin@example.com --role=administrator --user_pass=secret

WP-CLI runs as www-data inside the container, so it has the same filesystem permissions as WordPress itself.

Usage

# Start
docker compose up -d
# Stop
docker compose down
# View logs
docker compose logs -f

About

A Docker environment for WordPress - Production ready

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors