Nextcloud All-in-One on Docker: install it on a VPS or behind Caddy
Nextcloud All-in-One (AIO) is the install method the Nextcloud project itself recommends for Docker. One "mastercontainer" starts and updates everything else for you: Nextcloud, PostgreSQL, Redis, a web server with HTTPS, and optional extras like Talk, Office, ClamAV and built-in backups. This guide covers two setups: AIO on its own VPS, and AIO behind the Caddy proxy from the Docker and Caddy setup.
Everything below follows the official AIO readme and its reverse proxy guide. I haven't run these exact steps on a server for this post, so check the linked docs if something differs on your side.
What AIO is, and who it suits
AIO is the "one container to rule them all" approach. You start only the mastercontainer. It then creates the other containers itself through the Docker socket, and you manage them from a web interface. That makes it the easiest route to a complete Nextcloud, and also the least flexible: you don't write the compose file for the app stack, so you can't freely change it.
The official docs describe the included parts as Nextcloud, a PostgreSQL database, Redis and APCu caching, the notify push backend and an Apache container that handles HTTPS. Office (Collabora), Talk, ClamAV, full-text search, Imaginary previews, a whiteboard and BorgBackup are optional and switched on in the interface. Up to 100 users are free.
The docs give no RAM numbers, and Nextcloud is a heavy PHP app, so size the server before you order. The VPS size calculator and the small VPS RAM budget post help, and what to self-host first explains why many people start with lighter apps. If you only need file sync, check the Dropbox alternatives page too.
Before you start
- A domain pointing at the server. AIO checks this when you start the containers.
- Docker from Docker's own repository. The AIO docs say snap-based Docker is not supported. The Docker on Debian guide covers it.
- A real VM. The docs recommend KVM or non-virtualised servers and advise against some container-based VPS types. If
/proc/user_beancountersexists and shows a low process limit, the provider is likely using Virtuozzo, which the docs flag as a problem. - SSD storage is recommended.
- SELinux: if your distribution has it enabled, the docs say to add
security_opt: ["label=disable"]to the mastercontainer. - Data directory: if you want files somewhere other than the default Docker volume, set
NEXTCLOUD_DATADIRbefore the first install. Don't change it afterwards.
Do the first 15 minutes on a fresh VPS checklist first.
Path 1: AIO on its own VPS
This is the simplest setup and the one the readme is written for. The official compose file looks like this (comments removed):
name: nextcloud-aio
services:
nextcloud-aio-mastercontainer:
image: ghcr.io/nextcloud-releases/all-in-one:latest
init: true
restart: always
container_name: nextcloud-aio-mastercontainer
volumes:
- nextcloud_aio_mastercontainer:/mnt/docker-aio-config
- /var/run/docker.sock:/var/run/docker.sock:ro
network_mode: bridge
ports:
- "80:80"
- "8080:8080"
- "8443:8443"
volumes:
nextcloud_aio_mastercontainer:
name: nextcloud_aio_mastercontainer
The upstream file carries comments saying the container name and the volume name must not be changed, or AIO and its built-in backups stop working. Copy the current version from the AIO repository rather than from this page, because it can change.
mkdir -p ~/stack/nextcloud && cd ~/stack/nextcloud nano compose.yaml docker compose up -d
Ports: 8080 is the AIO interface (self-signed certificate), 8443 serves the same interface with a valid certificate once a domain points at the server, and port 80 is used for certificate validation. Open https://YOUR_SERVER_IP:8080, accept the certificate warning, and you get a passphrase. Save it somewhere safe, since you need it for the interface and for restoring backups. Then enter your domain and start the containers.
Your firewall needs 443/TCP and 443/UDP (HTTP/3) open, and 3478 TCP and UDP if you use Talk.
Docker ignores ufw, so don't leave 8080 open
Port 8080 is the admin interface. Published ports bypass ufw, as explained in Docker ignores ufw, so a "closed" 8080 is probably open to the internet. My suggestion (not from the AIO docs) is to publish it on localhost only and use an SSH tunnel when you need it:
ports:
- "80:80"
- "127.0.0.1:8080:8080"
- "8443:8443"
ssh -L 8080:localhost:8080 you@YOUR_SERVER_IP
Then browse to https://localhost:8080. The AIO page is protected by the passphrase, but nothing needs to be exposed all day for a screen you use a few times a year.
Path 2: behind the Caddy stack
If the server already runs other apps behind Caddy on ports 80 and 443, AIO can't also bind them. The AIO reverse proxy guide covers this: set APACHE_PORT so the built-in Apache listens on a different port, don't publish 80 and 8443, and point your proxy at it. The mastercontainer then looks like this:
services:
nextcloud-aio-mastercontainer:
image: ghcr.io/nextcloud-releases/all-in-one:latest
init: true
restart: always
container_name: nextcloud-aio-mastercontainer
volumes:
- nextcloud_aio_mastercontainer:/mnt/docker-aio-config
- /var/run/docker.sock:/var/run/docker.sock:ro
network_mode: bridge
ports:
- "127.0.0.1:8080:8080"
environment:
APACHE_PORT: 11000
APACHE_ADDITIONAL_NETWORK: stack_default
volumes:
nextcloud_aio_mastercontainer:
name: nextcloud_aio_mastercontainer
Replace stack_default with the name of the Docker network your Caddy container uses (docker network ls shows it). The AIO docs say this network must already exist before AIO starts, or the Apache container fails to start. With that set, Caddy reaches Nextcloud by name:
cloud.example.com {
reverse_proxy nextcloud-aio-apache:11000
}
The AIO docs list this as one of several options. The other two are running the proxy with host networking, or attaching the proxy to the nextcloud-aio network. If your proxy runs directly on the host, use reverse_proxy localhost:11000 and set APACHE_IP_BINDING: 127.0.0.1, which the docs recommend for that case.
If the proxy doesn't reach Nextcloud via localhost, Nextcloud may not trust it. The docs show adding it as a trusted proxy:
sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ config:system:set trusted_proxies 2 --value=PROXY_IP
Since no ports: entry publishes 11000, the Apache container is only reachable over that Docker network. Check with docker ps and the scan from the ufw post anyway.
First login and setup
Open the AIO interface (through your tunnel or on 8080), enter the domain, pick the optional containers, and start. Be sparing with the optional ones: each adds containers and memory use, and you can add them later.
When the containers are running, the interface shows the Nextcloud admin username and an initial password. While Nextcloud runs, direct login to the AIO interface with the passphrase is blocked. The docs' workaround is to log in to Nextcloud as admin, open https://yourdomain/settings/admin/overview and press the button at the top, which unlocks the AIO login for your browser session.
Backups
AIO has a built-in backup based on BorgBackup, configured in the interface. A restore needs the backup archive and the AIO passphrase, which is why you save the passphrase. Keep in mind that a backup on the same server isn't a backup of the server. Set the backup location to a different disk, then copy it off-site, for example with restic. The docs also describe optional daily backups from the interface, which can update the containers afterwards.
Updating
You update from the AIO interface: stop the containers, then use "Start and update containers". The mastercontainer itself has its own update step, shown in the interface. Because AIO controls the image versions, you don't pin tags the way described in updating Docker containers safely, but the principle holds: back up first (my advice, not a docs requirement), update, then check the admin overview.
Common problems
- Domain validation fails. The domain must point at the server and the proxy must reach
APACHE_PORT. Behind Cloudflare Tunnel or Pangolin, the docs say validation can't work and tell you to start withSKIP_DOMAIN_VALIDATION=true. - The 8080 page won't load in the browser. The certificate there is self-signed; use the IP address and accept the warning. The AIO docs say to always use the IP address on port 8080, because a domain may work at first and then break because of HSTS.
- Cloudflare in front of Nextcloud. The docs list caveats: Cloudflare terminates TLS, the free plan has a 100 MB upload limit and a 100 second timeout.
- Snap Docker. Not supported. Reinstall Docker from Docker's repository.
- Strange failures on a cheap VPS. Check the virtualization type, see "Before you start".
To compare plans, see the netcup VPS vouchers, and read root server vs VPS if your library is large.