An open API service indexing awesome lists of open source software.

https://github.com/hnthap/wordpress-docker

A containerized WordPress development setup using Docker Compose, featuring automated permission management and integrated database administration tools. Donate me: https://paypal.me/hnthap
https://github.com/hnthap/wordpress-docker

containerization database-management deployment docker docker-compose http-server mariadb permissions php php8 phpmyadmin sql wordpress

Last synced: 2 months ago
JSON representation

A containerized WordPress development setup using Docker Compose, featuring automated permission management and integrated database administration tools. Donate me: https://paypal.me/hnthap

Awesome Lists containing this project

README

          

# WordPress Development Environment with Docker

A containerized local WordPress development setup using Docker Compose. It includes automated permission management and integrated database administration tools for easier project setup and management.

Based on [@richardevcom’s tutorial](https://medium.com/@richardevcom/wordpress-development-environment-with-docker-ba52427bdd65).

## πŸš€ Features

- **Multi-container architecture** with WordPress, MariaDB, and phpMyAdmin
- **Automated file permission handling** for WordPress uploads and plugins
- **Environment-based configuration** for secure credential management
- **Database initialization** support with SQL dump integration
- **Development-optimized** with accessible local ports and volume mounting

## πŸ›  Technical Stack

- **WordPress**: PHP 8.2 with Apache
- **Database**: MariaDB 12.0.2
- **Containerization**: Docker & Docker Compose
- **Web Server**: Apache HTTP Server

### Development Tools
- **phpMyAdmin**: Database administration interface (optional)

## πŸ“‹ Prerequisites

- Docker Engine 20.10+
- Docker Compose 2.0+
- At least 2GB available RAM

## ⚑ Quick Start

1. **Clone and navigate to project**
```bash
git clone https://github.com/hnthap/wordpress-docker
cd wordpress-docker
```

2. **Configure environment variables**
```bash
cp .env.example .env
# .env.example uses simple passwords suitable for development.
# Change passwords in .env for production.
```

3. **Launch the application**
```bash
docker-compose up -d
```

4. **Access the services**
- WordPress: http://localhost:8080
- phpMyAdmin (optional): http://localhost:8180

## πŸ— Architecture Overview

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ WordPress β”œβ”€β”€β”€β”€β”€ MariaDB β”‚
β”‚ :8080 β”‚ β”‚ (internal) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
β”‚ phpMyAdmin β”‚
β”‚ :8180 β”‚
β”‚ (optional) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

**Key Design Decisions:**

- **Minimal Dependencies**: WordPress only depends on the database service it actually needs
- **Custom Dockerfile**: Implements automated permission fixing to resolve common WordPress file access issues
- **Volume Mounting**: Persistent data storage for both WordPress content and database
- **Optional Tooling**: phpMyAdmin included as a development convenience, not a core dependency
- **Environment Isolation**: Sensitive configuration separated from codebase

## πŸ“ Project Structure

```
wordpress-docker/
β”œβ”€β”€ docker-compose.yaml # Multi-service orchestration
β”œβ”€β”€ Dockerfile # Custom WordPress image with permission fixes
β”œβ”€β”€ .env # Environment configuration (not in repo)
β”œβ”€β”€ .env.example # Environment template file
β”œβ”€β”€ wp-content/ # WordPress content (themes, plugins, uploads)
β”œβ”€β”€ db_data/ # MariaDB data persistence
β”œβ”€β”€ dump.sql # Database initialization script (currently empty)
└── README.md # This documentation
```

## πŸ”§ Configuration

### Environment Variables (.env)

```bash
WORDPRESS_DB_USER=root
WORDPRESS_DB_PASSWORD=password

MYSQL_USER=root
MYSQL_PASSWORD=password
MYSQL_ROOT_PASSWORD=password
```

### Custom Docker Image Features

The custom Dockerfile extends the official WordPress image with:

- **Permission Management**: Automatic file ownership and permission correction
- **Startup Script**: Custom entrypoint that ensures proper WordPress file access
- **Security Hardening**: Proper file permissions (755 for directories, 644 for files)

## πŸ” Development Workflow

1. **File Changes**: Edit files in `./wp-content/` - changes reflect immediately
2. **Database Access**: Use phpMyAdmin at localhost:8180 for database management (or connect directly to MariaDB)
3. **Logs**: Monitor with `docker-compose logs -f [service-name]`
4. **Restart Services**: `docker-compose restart [service-name]`

> **Note**: phpMyAdmin is included as a development convenience but can be removed from docker-compose.yaml if not needed, as WordPress doesn't depend on it.

## πŸš€ Production Considerations

For production deployment, consider:

- [ ] Implement health checks for all services
- [ ] Add SSL/TLS termination
- [ ] Configure backup strategies for database and content
- [ ] Implement proper secrets management
- [ ] Add monitoring and logging solutions
- [ ] Set up reverse proxy with Nginx

## πŸ› Troubleshooting

### WordPress Installation Issues

- Verify database connection in wp-config.php
- Check file permissions in wp-content directory
- Ensure all containers are running: `docker-compose ps`

## πŸ“š Learning Resources

This project demonstrates proficiency in:
- **Containerization**: Custom Docker image creation and composition
- **Web Development**: PHP-based application deployment
- **Database Management**: Relational database integration
- **DevOps Practices**: Environment configuration and service orchestration

## 🀝 Contributing

1. Fork the repository
2. Create a feature branch: `git checkout -b `
3. Commit changes: `git commit -m "Add feature description"`
4. Push to branch: `git push origin `
5. Submit a pull request

---

**Built with ❀️ using Docker, WordPress, and industry-standard containerization practices**