Nextcloud
A self-hosted Nextcloud file sync and collaboration platform fronted by Nginx and backed by MariaDB and Redis. The Nextcloud FPM image runs the PHP application while Nginx serves static assets and proxies PHP requests, providing better performance than the all-in-one Apache image. MariaDB 11.4 stores all user data, file metadata, and application state, while Redis 7 handles transactional file locking and memory caching to reduce database load. All user files are persisted in a dedicated named volume and the frontend/backend network separation ensures the database and cache are not publicly accessible. Health checks on every service guarantee correct startup ordering and readiness.
Servicios Incluidos
nginx
nginx:1.27-alpine
nextcloud
nextcloud:30-fpm-alpine
Variables de Entorno:
mariadb
mariadb:11.4
Variables de Entorno:
redis
redis:7-alpine
YAML Generado
# Generated by ComposeHub (composehub.dev)
name: nextcloud
services:
nginx:
image: nginx:1.27-alpine
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- nginx_conf:/etc/nginx/conf.d
- nextcloud_data:/var/www/html:ro
networks:
- frontend
- backend
depends_on:
nextcloud:
condition: service_healthy
healthcheck:
test:
- CMD
- curl
- "-f"
- http://localhost
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: "0.50"
memory: 256M
reservations:
cpus: "0.10"
memory: 64M
labels:
com.composeforge.description: Nginx reverse proxy for Nextcloud
nextcloud:
image: nextcloud:30-fpm-alpine
restart: unless-stopped
expose:
- "9000"
volumes:
- nextcloud_data:/var/www/html
- nextcloud_custom_apps:/var/www/html/custom_apps
- nextcloud_config:/var/www/html/config
- nextcloud_themes:/var/www/html/themes
environment:
MYSQL_HOST: mariadb
MYSQL_DATABASE: ${MYSQL_DATABASE:-nextcloud}
MYSQL_USER: ${MYSQL_USER:-nextcloud}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-changeme}
NEXTCLOUD_ADMIN_USER: ${NEXTCLOUD_ADMIN_USER:-admin}
NEXTCLOUD_ADMIN_PASSWORD: ${NEXTCLOUD_ADMIN_PASSWORD:-changeme}
NEXTCLOUD_TRUSTED_DOMAINS: ${NEXTCLOUD_TRUSTED_DOMAINS:-localhost}
REDIS_HOST: redis
REDIS_HOST_PORT: "6379"
OVERWRITEPROTOCOL: ${OVERWRITEPROTOCOL:-https}
OVERWRITECLIURL: ${OVERWRITECLIURL:-https://localhost}
PHP_MEMORY_LIMIT: ${PHP_MEMORY_LIMIT:-512M}
PHP_UPLOAD_LIMIT: ${PHP_UPLOAD_LIMIT:-10G}
networks:
- backend
depends_on:
mariadb:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- php-fpm-healthcheck || kill -0 1
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
deploy:
resources:
limits:
cpus: "2.00"
memory: 1024M
reservations:
cpus: "0.50"
memory: 256M
labels:
com.composeforge.description: Nextcloud PHP-FPM application server
mariadb:
image: mariadb:11.4
restart: unless-stopped
command:
- "--innodb-buffer-pool-size=512M"
- "--innodb-log-file-size=128M"
- "--innodb-flush-method=O_DIRECT"
- "--innodb-file-per-table=1"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
- "--transaction-isolation=READ-COMMITTED"
- "--binlog-format=ROW"
volumes:
- mariadb_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootchangeme}
MYSQL_DATABASE: ${MYSQL_DATABASE:-nextcloud}
MYSQL_USER: ${MYSQL_USER:-nextcloud}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-changeme}
networks:
- backend
healthcheck:
test:
- CMD
- healthcheck.sh
- "--connect"
- "--innodb_initialized"
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
deploy:
resources:
limits:
cpus: "1.00"
memory: 768M
reservations:
cpus: "0.25"
memory: 256M
labels:
com.composeforge.description: MariaDB 11.4 database for Nextcloud
redis:
image: redis:7-alpine
restart: unless-stopped
command:
- redis-server
- "--maxmemory"
- 128mb
- "--maxmemory-policy"
- allkeys-lru
- "--appendonly"
- yes
- "--appendfsync"
- everysec
- "--save"
- "60"
- "1000"
volumes:
- redis_data:/data
networks:
- backend
healthcheck:
test:
- CMD
- redis-cli
- ping
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: "0.50"
memory: 192M
reservations:
cpus: "0.10"
memory: 64M
labels:
com.composeforge.description: Redis 7 for Nextcloud file locking and caching
networks:
frontend:
driver: bridge
backend:
driver: bridge
volumes:
nextcloud_data:
driver: local
nextcloud_custom_apps:
driver: local
nextcloud_config:
driver: local
nextcloud_themes:
driver: local
mariadb_data:
driver: local
redis_data:
driver: local
nginx_conf:
driver: local
Información Rápida
- Servicios
- 4
- Redes
- 2
- Volúmenes
- 7
Cuándo Usar
Esta plantilla es ideal para configurar un entorno de nextcloud Todos los servicios vienen preconfigurados con healthchecks, límites de recursos y valores por defecto sensatos. Personaliza las variables de entorno antes de desplegar en producción.
Consejos
- Cambia todas las contraseñas por defecto antes de desplegar
- Revisa los límites de recursos para tu hardware
- Añade un proxy inverso para HTTPS en producción
- Configura estrategias de respaldo para los volúmenes de datos