Part 4 – Nextcloud
Nextcloud is a self-hosted file sync and collaboration platform — your own Google Drive, running on your own hardware. Files sync between all your devices, never leaving your network.
What you get:
- File sync across Mac, iPhone, iPad, Android, and Windows
- Calendar and contacts sync (CalDAV/CardDAV)
- Photo backup
- Document editing via OnlyOffice or Collabora (optional)
- Mobile apps for iOS and Android
Prerequisites
- ✅ Docker and the
wcp-networknetwork in place - ✅ Caddy running with
nextcloud.wcpconfigured - ✅
/optpartition with plenty of space for files
→ Follow Part 2 and Part 3 first.
Step 1 – Create the Nextcloud folder
mkdir -p /opt/docker/nextcloud
cd /opt/docker/nextcloudStep 2 – Create the compose.yml
nano compose.ymlservices:
nextcloud-db:
image: mariadb:11
container_name: nextcloud-db
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
- nextcloud-db:/var/lib/mysql
networks:
- wcp-network
restart: unless-stopped
nextcloud-redis:
image: redis:alpine
container_name: nextcloud-redis
networks:
- wcp-network
restart: unless-stopped
nextcloud:
image: nextcloud:latest
container_name: nextcloud
depends_on:
- nextcloud-db
- nextcloud-redis
environment:
MYSQL_HOST: nextcloud-db
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_PASSWORD: ${DB_PASSWORD}
REDIS_HOST: nextcloud-redis
NEXTCLOUD_TRUSTED_DOMAINS: nextcloud.wcp
NEXTCLOUD_ADMIN_USER: ${ADMIN_USER}
NEXTCLOUD_ADMIN_PASSWORD: ${ADMIN_PASSWORD}
volumes:
- nextcloud-data:/var/www/html
- /opt/nextcloud-files:/var/www/html/data
networks:
- wcp-network
restart: unless-stopped
volumes:
nextcloud-db:
nextcloud-data:
networks:
wcp-network:
external: trueStep 3 – Create the .env file
nano .envDB_ROOT_PASSWORD=change-this-root-password
DB_PASSWORD=change-this-db-password
ADMIN_USER=admin
ADMIN_PASSWORD=change-this-admin-password.env to .gitignore if you version control your Docker configs — never commit passwords to a repository.Step 4 – Create the data directory
Nextcloud files are stored outside the container for easy backup:
sudo mkdir -p /opt/nextcloud-files
sudo chown -R www-data:www-data /opt/nextcloud-filesStep 5 – Start Nextcloud
docker compose up -d
docker compose logs -fThe first start takes a minute while Nextcloud initialises. When you see Nextcloud is ready in the logs, press CTRL+C.
Step 6 – Access Nextcloud
Open your browser and go to:
http://nextcloud.wcpLog in with the admin username and password from your .env file.
Step 7 – Performance tuning
Run these one-time setup commands inside the container:
# Enable background jobs via cron
docker exec -u www-data nextcloud php occ background:cron
# Add missing indices (speeds up the database)
docker exec -u www-data nextcloud php occ db:add-missing-indices
# Convert columns for better performance
docker exec -u www-data nextcloud php occ db:convert-filecache-bigintAdd a cron job on the host for background tasks:
crontab -eAdd:
*/5 * * * * docker exec -u www-data nextcloud php -f /var/www/html/cron.phpStep 8 – Install the Nextcloud client
Install the desktop sync client on your Mac:
brew install --cask nextcloudOpen the app, connect to http://nextcloud.wcp and log in. Your files will sync automatically.
Mobile apps are available on the App Store and Google Play.
Keeping Nextcloud updated
cd /opt/docker/nextcloud
docker compose pull
docker compose up -dRelated guides
- Part 3 – Caddy Reverse Proxy — required for
nextcloud.wcpto work - Install Docker and Docker Compose on Linux — Docker basics
- Nextcloud Documentation — official docs