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
- Host: GitHub
- URL: https://github.com/hnthap/wordpress-docker
- Owner: hnthap
- License: mit
- Created: 2025-08-22T03:45:08.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-22T15:19:48.000Z (10 months ago)
- Last Synced: 2025-09-20T10:48:40.542Z (9 months ago)
- Topics: containerization, database-management, deployment, docker, docker-compose, http-server, mariadb, permissions, php, php8, phpmyadmin, sql, wordpress
- Language: Dockerfile
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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**