3.7 KiB
3.7 KiB
Nextcloud Docker Container
A production-ready Docker container setup for Nextcloud using Alpine Linux, Nginx, PHP-FPM, and PostgreSQL.
Features
- 🐳 Dockerized Nextcloud instance with optimal configuration
- 🏔 Alpine Linux base image for minimal footprint
- 🚀 Nginx + PHP-FPM 8.2 performance stack
- 🐘 PostgreSQL database integration
- 🔄 Redis caching for improved performance
- 🔒 Automatic SSL configuration support
- 📦 Persistent storage for data and configurations
- 📊 Built-in health monitoring and metrics
Getting Started
1. Clone Repository
git clone https://git.esculta.es/aesculta/nextcloud.git
cd nextcloud
2. Directory Structure
.
├── docker-compose.yml
├── Dockerfile
├── config/
│ ├── nginx/
│ ├── php/
│ └── redis/
├── entrypoint.sh
├── .env.example
└── README.md
3. Environment Setup
- Copy environment template:
cp .env.example .env - Edit
.envfile:# Database POSTGRES_USER=nextcloud POSTGRES_PASSWORD=strongpassword POSTGRES_DB=nextcloud # Nextcloud NEXTCLOUD_ADMIN_USER=admin NEXTCLOUD_ADMIN_PASSWORD=secureadminpass NEXTCLOUD_TRUSTED_DOMAINS=cloud.example.com # Redis REDIS_PASSWORD=redispass # Generate secrets with: openssl rand -base64 48 NEXTCLOUD_SECRET=generate_strong_secret POSTGRES_SECRET=generate_strong_secret
4. Start Containers
docker-compose build --no-cache && docker-compose up -d
Configuration
Services Architecture
graph TD
A[User] --> B[Nginx:80/443]
B --> C[PHP-FPM:9000]
C --> D[PostgreSQL:5432]
C --> E[Redis:6379]
F[pgAdmin] --> D
Port Mapping
| Service | Port | Protocol | Description |
|---|---|---|---|
| Nextcloud | 8080 | HTTP | Web Interface |
| PostgreSQL | 5432 | TCP | Database Access |
| pgAdmin | 5050 | HTTP | DB Management |
Maintenance
Backup Data
# Create backup archive
docker run --rm --volumes-from nextcloud-app -v $(pwd)/backups:/backup alpine \
tar czf /backup/nextcloud-$(date +%Y-%m-%d).tar.gz /var/www/html
Update Nextcloud
- Pull latest images:
docker-compose pull - Recreate containers:
docker-compose down && docker-compose up -d - Run upgrade:
docker exec -it nextcloud-app php occ upgrade
Security Best Practices
- Enable HTTPS: Modify
nginx/ssl.confwith your SSL certificates - Regular Updates:
docker-compose pull && docker-compose build --no-cache - Database Backups:
docker exec postgres pg_dump -U nextcloud nextcloud > backup.sql - Firewall Rules:
ufw allow 80/tcp ufw allow 443/tcp ufw enable
Troubleshooting
Common Issues
Issue: File upload size limitations
Fix: Adjust PHP settings in config/php/php.ini:
upload_max_filesize = 16G
post_max_size = 16G
Issue: Database connection errors
Verify:
docker exec -it postgres psql -U nextcloud -d nextcloud
Issue: Slow performance
Optimize:
docker exec -it nextcloud-app php occ files:scan --all
docker exec -it nextcloud-app php occ maintenance:repair
License
GPL v3.0 - See LICENSE for details
Note
: For production deployments, consider adding:
- Reverse proxy with HTTPS termination
- Monitoring (Prometheus/Grafana)
- Regular backup automation
- Resource limits in docker-compose.yml