1 wordpress
Luca Matteo Spoljarevic edited this page 2026-02-27 21:45:51 +01:00

WordPress

This setup runs WordPress and MariaDB with Podman Compose. WordPress is served on a configurable port and uses a .env file for database and credentials.


What the compose file does

Service: wordpress

  • Image: docker.io/library/wordpress:latest
  • Port: 8040 → container 80
  • Config: env_file: .env and environment variables for DB host, user, password, and database name
  • Role: Web server and PHP app; connects to the db service

Service: db

  • Image: docker.io/library/mariadb:10.6.4-focal
  • Command: Uses mysql_native_password for compatibility with WordPress
  • Volume: Named volume db_data for /var/lib/mysql
  • Config: env_file: .env — root password, database name, and user/password (must match WordPress vars)

Volume

  • db_data — persists MariaDB data across restarts

Environment file

The stack expects a .env file in the same directory as podman-compose.yml. Use env.example as a template:

# WordPress → MariaDB
WORDPRESS_DB_HOST=db
WORDPRESS_DB_USER=wordpress
WORDPRESS_DB_PASSWORD=SuperSecret!
WORDPRESS_DB_NAME=wordpress

# MariaDB
MYSQL_ROOT_PASSWORD=RootPass123!
MYSQL_DATABASE=wordpress
MYSQL_USER=wordpress
MYSQL_PASSWORD=SuperSecret!

Important: Use strong, unique passwords in production and do not commit .env to version control.


Prerequisites

  • Podman and Podman Compose installed
  • Copy env.example to .env and set your passwords (and optionally DB name/user).

How to use

  1. Go to the project folder:

    cd wordpress
    
  2. Create .env:

    cp env.example .env
    

    Edit .env and set strong values for WORDPRESS_DB_PASSWORD, MYSQL_ROOT_PASSWORD, and MYSQL_PASSWORD.

  3. Start the stack:

    podman-compose up -d
    
  4. Open WordPress:
    http://<your-host>:8040
    Complete the famous “5-minute” WordPress installation (site title, admin user, etc.).

  5. Stop:

    podman-compose down
    

Database data is stored in the db_data volume, so it persists across down/up.


Useful commands

Action Command
Start podman-compose up -d
Stop podman-compose down
Logs podman-compose logs -f
Restart podman-compose restart

Customization

  • Change the host port by editing 8040:80 under wordpressports.
  • To use different DB credentials or database name, update both the WORDPRESS_* and MYSQL_* entries in .env so they stay in sync.