Nextcloud turns a cheap VPS into your own file cloud: file sync across devices, calendar, contacts, notes, and photo backup — without a monthly per-GB bill. This guide uses Docker Compose, which is the least painful way to run and update it.
Prerequisites
- A VPS with 2 GB RAM or more (see which VPS to pick), running a recent Ubuntu/Debian.
- A domain (e.g.
cloud.yourdomain.com) pointed at the server — see how to point a domain to a VPS. - Docker + Docker Compose installed.
Step 1 — Create the Compose file
Create a folder and a docker-compose.yml:
services:
db:
image: mariadb:11
restart: always
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
volumes:
- db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: change_me_root
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_PASSWORD: change_me
app:
image: nextcloud:stable
restart: always
ports:
- "8080:80"
depends_on:
- db
volumes:
- nextcloud:/var/www/html
environment:
MYSQL_HOST: db
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_PASSWORD: change_me
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: change_me_admin
NEXTCLOUD_TRUSTED_DOMAINS: cloud.yourdomain.com
volumes:
db:
nextcloud:
Change every change_me* value and set NEXTCLOUD_TRUSTED_DOMAINS to your real subdomain.
Step 2 — Start it
docker compose up -d
docker compose logs -f app # watch until it's ready
Nextcloud is now listening on port 8080 on the server (not public yet).
Step 3 — Add HTTPS with a reverse proxy
Don’t expose port 8080 directly. Put Nginx Proxy Manager in front, point cloud.yourdomain.com → http://app:80 (or the host’s :8080), and let it issue a free Let’s Encrypt certificate. Full walkthrough: Nginx Proxy Manager setup.
Step 4 — First-run setup
Open https://cloud.yourdomain.com, log in with the admin user you set, and install the apps you want (Calendar, Contacts, Notes, Photos). For better performance with several users, add Redis for file locking — but the stack above is fine to start.
Which VPS to run it on
Nextcloud is light for one person but disk-hungry once you sync photos. A 2 GB managed instance on Cloudways is the hands-off option; a cheap Hetzner box is the best value if you’re comfortable on the CLI. Full comparison: Best VPS for Self-Hosting. For China access, see the BandwagonHost HK review.