Skip to content

micro-pi/docker-wordpress-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Build Status

🐳 Docker WordPress + Nginx

A lightweight Docker-based setup for running WordPress with Nginx and PHP-FPM.
Ideal for local development, testing, or quick deployment scenarios.

πŸš€ Features

  • WordPress served via Nginx and PHP-FPM
  • MariaDB container included (drop-in MySQL replacement)
  • Adminer lightweight web-based database browser
  • Managed through Docker Compose for easy orchestration
  • Clean, modular structure for extending or customizing services

🧰 Tech Stack

  • Docker & Docker Compose
  • Nginx
  • PHP-FPM
  • WordPress
  • MariaDB
  • Adminer (for DB management)

πŸ“¦ Folder Structure

docker-wordpress-nginx/
β”œβ”€β”€ .env                   # Environment variables for WordPress and MariaDB configuration
β”œβ”€β”€ docker-compose.yml     # Defines services for WordPress, MariaDB, Nginx, PHP-FPM, and Adminer
β”œβ”€β”€ .github/               # GitHub Actions CI/CD configuration
β”‚    └── workflows/
β”‚        └──docker-ci.yml  # GitHub workflow for building/testing Docker images
β”œβ”€β”€ nginx/                 # Nginx service
β”‚   β”œβ”€β”€ default.conf       # Nginx configuration for serving WordPress
β”‚   └── Dockerfile         # Custom Nginx image
β”œβ”€β”€ php/                   # PHP-FPM service
β”‚   β”œβ”€β”€ Dockerfile         # Custom PHP image
β”‚   └── wordpress/         # WordPress source files
β”‚       └── readme.txt
└── mariadb/               # (optional) MariaDB initialization scripts
    └── init.sql

πŸ› οΈ Getting Started

  1. Clone the repository
git clone https://github.com/micro-pi/docker-wordpress-nginx.git
cd docker-wordpress-nginx
  1. Configure your environment Edit the .env file to set your personal database credentials:
# WordPress settings
WORDPRESS_DB_NAME=your_db_name
WORDPRESS_DB_USER=your_db_user
WORDPRESS_DB_PASSWORD=your_db_password

# MariaDB settings
MYSQL_ROOT_PASSWORD=your_root_password
MYSQL_DATABASE=your_db_name
MYSQL_USER=your_db_user
MYSQL_PASSWORD=your_db_password

# Optional: Adminer port
ADMINER_PORT=8080
  1. Build and Start the Docker containers
docker compose up -d

This builds and launches WordPress, Nginx, PHP-FPM, MariaDB, and Adminer containers in detached mode.

To check running containers:

docker compose ps

πŸš€ Running Containers

NAME         IMAGE             COMMAND                  SERVICE   CREATED          STATUS         PORTS
wp_adminer   adminer:latest    "entrypoint.sh docke…"   adminer   10 minutes ago   Up 9 minutes   0.0.0.0:8181->8080/tcp, [::]:8181->8080/tcp
wp_db        mariadb:latest    "docker-entrypoint.s…"   db        10 minutes ago   Up 9 minutes   0.0.0.0:3307->3306/tcp, [::]:3307->3306/tcp
wp_nginx     wp_nginx:latest   "/docker-entrypoint.…"   nginx     9 minutes ago    Up 9 minutes   0.0.0.0:8081->80/tcp, [::]:8081->80/tcp
wp_php       wp_php:latest     "docker-php-entrypoi…"   php       10 minutes ago   Up 9 minutes   9000/tcp
  1. Access your WordPress site Open your browser and visit:
  1. Stop and clean up To stop the stack and remove all containers and volumes:
docker compose down -v

πŸ”Ή WordPress

Setup Configuration WordPress Setup Configuration File

Dashboard WordPress Dashboard

Home Page WordPress Home Page

🐳 Docker Status

Below you can see the local Docker environment after building the stack.

🧱 Images

PS D:\workspaces\docker-workspace\docker-wordpress-nginx> docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
wp_php       latest    c48d427debfc   7 minutes ago   822MB
wp_php       latest    c48d427debfc   7 minutes ago   822MB
wp_nginx     latest    dc0cdfddea42   30 hours ago    225MB
adminer      latest    b1d44e230bed   11 days ago     168MB
mariadb      latest    5b6a1eac15b8   2 months ago    456MB

πŸ“Έ Docker Desktop – Images View

Docker Desktop – Images View

πŸš€ Running Containers

PS D:\workspaces\docker-workspace\docker-wordpress-nginx> docker ps
CONTAINER ID   IMAGE             COMMAND                  CREATED         STATUS         PORTS                                         NAMES
9a5ef764da35   wp_nginx:latest   "/docker-entrypoint.…"   7 minutes ago   Up 7 minutes   0.0.0.0:8081->80/tcp, [::]:8081->80/tcp       wp_nginx
a0dbf4566285   adminer:latest    "entrypoint.sh docke…"   7 minutes ago   Up 7 minutes   0.0.0.0:8181->8080/tcp, [::]:8181->8080/tcp   wp_adminer
8a65218f5b09   wp_php:latest     "docker-php-entrypoi…"   7 minutes ago   Up 7 minutes   9000/tcp                                      wp_php
3163cebdf6f6   mariadb:latest    "docker-entrypoint.s…"   7 minutes ago   Up 7 minutes   0.0.0.0:3307->3306/tcp, [::]:3307->3306/tcp   wp_db

πŸ“Έ Docker Desktop – Running Containers

Docker Desktop – Running Containers

πŸ—„οΈDatabase Configuration

The setup includes a MariaDB container with default credentials (customizable via .env): Default values (for local use):

Variable Default
MYSQL_DATABASE wordpress
MYSQL_USER wordpress
MYSQL_PASSWORD wordpress
MYSQL_ROOT_PASSWORD root

You can also make the database accessible externally using:

DB_BIND_ADDRESS=0.0.0.0

βš™οΈ Customization

You can tweak the following .env variables to fit your environment:

Variable Description Default
NGINX_PORT Public port for WordPress 8081
ADMINER_PORT Exposed Adminer port 8080
DB_PORT Exposed MariaDB port 3306
DB_BIND_ADDRESS Database bind address 127.0.0.1

To apply changes after editing .env:

docker compose build
docker compose up -d

🧩 Database Browser (Adminer)

This setup includes Adminer β€” a lightweight, single-file database management tool for MariaDB/MySQL. It provides a simple web interface to explore, query, and manage your WordPress database.

πŸ”Ή Configuration Adminer is defined as a separate service in docker-compose.yml:

adminer:
  image: adminer:latest
  container_name: wp_adminer
  depends_on:
    - db
  ports:
    - ${ADMINER_PORT}:8080
  environment:
    ADMINER_DEFAULT_SERVER: db

πŸ”Ή Environment Variable Add to your .env file (if not already present):

ADMINER_PORT=8080

πŸ”Ή Usage

  1. Start the stack:
docker compose up -d
  1. Open Adminer:

(or http://localhost:${ADMINER_PORT} if changed)

  1. Log in using your database credentials:
Field Value
System MySQL
Server db
Username ${MYSQL_USER} or root
Password ${MYSQL_PASSWORD} or ${MYSQL_ROOT_PASSWORD}
Database ${MYSQL_DATABASE}

πŸ–ΌοΈ Adminer Screenshots

Login Page Adminer Login

Database Selection Adminer Select Database

🧩 Troubleshooting

πŸ›‘ Port already in use

# Change port in .env (e.g. NGINX_PORT=8082) and restart
docker compose down
docker compose up -d

πŸ”‘ Permission denied for WordPress files

sudo chown -R www-data:www-data wordpress

βš™οΈ Database connection errors

  • Ensure the db container is running:
docker compose ps
  • Check your .env values (especially WORDPRESS_DB_HOST).

πŸ” View logs

docker compose logs -f

πŸ€– Continuous Integration

This project includes a GitHub Actions workflow:

.github/workflows/docker-ci.yml

It automatically:

  • Builds all Docker images
  • Verifies syntax and configuration
  • Prepares images for deployment/testing

🀝 Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you’d like to improve.

πŸ“„ License

This project is open source and available under the MIT License.

About

A lightweight Docker-based setup for running WordPress with Nginx and PHP-FPM.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published