Self-Hosting Nextcloud With Docker
Set up Nextcloud with Docker using the official All-in-One stack. Follow steps for HTTPS, domain setup, Compose, backups, and choosing the community image.
The official way to run Nextcloud in Docker is Nextcloud All-in-One (AIO): you start one mastercontainer with a single docker run command, and it creates, updates and backs up every other container Nextcloud needs.
Search for “nextcloud docker” and most results are forks, mirrors or old guides that have you assemble Nextcloud, MariaDB, Redis and a TLS proxy by hand. You then maintain all of it yourself, and the first major upgrade is where those setups usually break.
This guide covers the supported path. You run the official command, finish setup in a browser, get HTTPS with a real certificate, and move to Compose for long-term use. It also explains when the community image is the better choice.
Key Takeaways
- Nextcloud All-in-One is the installation method maintained by Nextcloud GmbH. Its mastercontainer image is
ghcr.io/nextcloud-releases/all-in-one:latest. - Open the AIO setup interface at
https://<server-ip>:8080using the IP address, not a domain. Port 8080 always serves a self-signed certificate, and HSTS on your domain can block it later. - Ports 80 and 8443 let the mastercontainer get a valid certificate for its own interface. Nextcloud itself is served on 443, and 3478 TCP/UDP is needed only for Talk.
- AIO’s README recommends its example Compose file over
docker runfor production use. - The community
nextcloudimage is maintained by volunteers, is designed for expert use, and uses SQLite unless you configure a database.
What Is Nextcloud and Who Is This Setup For?
Nextcloud is self-hosted file sync and sharing software. It replaces Google Drive or Dropbox with storage that runs on hardware you control, and it has desktop and mobile clients, sharing links and an optional office suite. This setup is for developers who have a home server, a NAS or a cheap Linux VPS and are comfortable with Docker and SSH.
AIO needs a real Docker Engine. Install it from the official Docker Engine instructions. Snap-based Docker installations are not supported (this mainly affects Ubuntu), so check how Docker was installed and migrate away from Snap before you continue. AIO’s documentation doesn’t state a minimum Docker version.
Why Is Nextcloud AIO the Recommended Nextcloud Docker Path?
Nextcloud AIO is the installation method Nextcloud GmbH designates as official. One mastercontainer, started with a single docker run command, creates and manages the other containers Nextcloud needs. You don’t write a database service, a cache service or a proxy config. The mastercontainer handles them and also takes care of:
- Updates. You update the mastercontainer and the stack it manages from the AIO interface.
- Certificates. AIO obtains TLS certificates for your domain automatically.
- Backups. These are built on BorgBackup and are incremental, compressed and encrypted. Save the encryption key the interface shows you, because you can’t restore any backup without it.
According to the AIO README, up to 100 users are free, and larger deployments are possible with Nextcloud Enterprise.
Run the Mastercontainer
To install Nextcloud AIO, start the mastercontainer with this command, taken exactly from the AIO README. It applies to Linux servers that don’t already have a web server or reverse proxy in place:
sudo docker run \
--init \
--sig-proxy=false \
--name nextcloud-aio-mastercontainer \
--restart always \
--publish 80:80 \
--publish 8080:8080 \
--publish 8443:8443 \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
ghcr.io/nextcloud-releases/all-in-one:latest
Here is what each part does:
--initruns a small init process as PID 1 inside the container. It forwards signals and reaps zombie processes, as described in thedocker runreference.--sig-proxy=falsestops your terminal from passing signals to the container, so pressing Ctrl+C detaches from the logs without stopping AIO.--name nextcloud-aio-mastercontainermust not change. Mastercontainer updates and the built-in backups depend on this name.--restart alwaysbrings the mastercontainer back after a reboot or a crash.--publish 80/8080/8443exposes the setup interface and the certificate ports. If something already uses host port 8080, the README says you can map a different host port, for example--publish 8081:8080.nextcloud_aio_mastercontaineris the named volume that holds AIO’s configuration. Keep this name unchanged as well./var/run/docker.sock:rogives the mastercontainer read-only access to the Docker socket. That lets it create, update and stop its sibling containers through the Docker API, the same way Portainer works.
Open the Setup Interface on Port 8080
After the Nextcloud AIO mastercontainer starts, open https://<server-ip>:8080 in a browser, using the server’s IP address. Port 8080 always serves a self-signed certificate, so the browser shows a warning that you have to accept.
Don’t open this port by domain name. When your domain starts sending HSTS headers later, browsers will refuse the certificate click-through for that host, as RFC 6797 requires, and you won’t be able to reach the interface by domain any more. The IP address avoids this.
The interface gives you a passphrase. Store it somewhere safe, because you need it every time you log in to AIO.
Configure a Domain and HTTPS
Nextcloud AIO requires a domain. It doesn’t serve Nextcloud on a bare IP address or with a self-signed certificate. Point a DNS record at your server, forward the ports listed below, and enter the domain in the interface. If you don’t have a domain, the interface can register a free dedyn.io subdomain through deSEC. It keeps the DNS record up to date and enables the Caddy community container as the reverse proxy, plus a dnsmasq container for local DNS resolution. Check that this option is available before you rely on it: deSEC suspended new dedyn.io registrations on September 21, 2026 and gave no date for reopening them. If registration is closed, use a domain of your own.
| Port | Protocol | Used for | Needed when |
|---|---|---|---|
| 8080 | TCP | AIO interface, self-signed certificate | Initial setup |
| 80 | TCP | ACME HTTP challenge for the interface certificate | No reverse proxy in front |
| 8443 | TCP | AIO interface with a valid certificate | No reverse proxy in front |
| 443 | TCP | Nextcloud itself | Always |
| 443 | UDP | HTTP/3 | Optional |
| 3478 | TCP + UDP | Talk TURN server | Talk is enabled |
Once DNS resolves and ports 80 and 8443 are reachable, you can open the interface at https://<your-domain>:8443 with a valid certificate.
Behind a Reverse Proxy
If nginx, Caddy, Cloudflare Tunnel or another reverse proxy already handles TLS on your server, you don’t need to publish ports 80 and 8443. Don’t use the command above as written. Follow AIO’s reverse proxy documentation instead, which has you set APACHE_PORT so that your proxy forwards traffic to the Nextcloud container.
Move to Compose for Production
The AIO README recommends its example compose.yaml over docker run for production, because a Compose file makes upgrades and configuration changes easier. The file is also where the customization options are documented as comments.
When you switch, keep the container name nextcloud-aio-mastercontainer and the volume nextcloud_aio_mastercontainer exactly as they are. AIO’s updates and its backup solution expect those names, so changing them breaks both.
The Expert Option: The Community Nextcloud Image
The community nextcloud image on Docker Hub is maintained by community volunteers and designed for expert use. Its own documentation points people who want a quick, easy deployment to AIO. The image’s quick-start command is:
docker run -d -p 8080:80 nextcloud
That command serves Nextcloud at http://localhost:8080/, but it’s meant only for limited testing. The image uses SQLite by default. To use MySQL/MariaDB or PostgreSQL, you either set the full group of database environment variables or connect to an existing database in the setup wizard on first run. HTTPS, backups and the database container are all yours to build and maintain.
| Nextcloud AIO | Community nextcloud image | |
|---|---|---|
| Maintainer | Nextcloud GmbH | Community volunteers |
| Intended user | Most self-hosters | Experts |
| Database | Created and managed by AIO | SQLite unless you configure one |
| HTTPS | Built in | You supply the proxy and TLS |
| Backups | BorgBackup, built in | None |
| Updates | From the AIO interface | Pull and recreate the container yourself, one major version at a time |
Conclusion
Use Nextcloud All-in-One unless you have a specific reason to build the stack yourself. Install Docker Engine from Docker’s own packages rather than Snap, then run the mastercontainer command. Open port 8080 by IP address, add a domain, and save your passphrase and backup key. When the instance works, move it to the example compose.yaml with the same container and volume names, and it’s ready for long-term use.
FAQs
How do I run occ commands in a Nextcloud AIO installation?
Run occ inside the Nextcloud container as the www-data user: sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ your-command, replacing your-command with the occ command you need. Leaving out --user www-data makes occ fail, because it must run as the user that owns config.php. The same pattern covers routine tasks such as files:scan --all or security:bruteforce:reset followed by an IP address.
How do I increase the upload limit in Nextcloud AIO?
Set the NEXTCLOUD_UPLOAD_LIMIT environment variable on the mastercontainer, for example --env NEXTCLOUD_UPLOAD_LIMIT=10G, placed before the image line of the docker run command. The value must start with a number and end with G. The AIO README gives a 1G default for non-chunked uploads, while the web interface and clients upload larger files in chunks. On an existing install, remove and recreate the mastercontainer. No data is lost.
What can I do if I lose the AIO interface passphrase?
Read it back from the mastercontainer's configuration file with sudo docker exec nextcloud-aio-mastercontainer grep password /mnt/docker-aio-config/data/configuration.json. The passphrase is the value of the password field in the output. It is stored in the nextcloud_aio_mastercontainer volume, so the command works only while that volume exists, which is one more reason never to rename or delete it.
Can I migrate an existing Nextcloud installation to AIO?
Yes. The migration.md guide in the AIO repository describes three routes. Migrating only the files is the easiest, but it leaves out data such as calendars. Migrating the files and the database keeps everything, but it is much more complicated and requires the old instance's Nextcloud version to match AIO's. The user_migration app moves the most important data, but you have to run it manually for each user.
Gain Debugging Superpowers
Unleash the power of session replay to reproduce bugs, track slowdowns and uncover frustrations in your app. Get complete visibility into your frontend with OpenReplay — the most advanced open-source session replay tool for developers.
Star on GitHub12k