Self-hosting Nextcloud with Docker: Self-hosting handbook
Welcome to the fifth page of a handbook on self-hosting. Begin here. Read the previous page here. On this page, we’ll cover self-hosting Nextcloud with Docker (
docker-compose, more specifically) on top of the stack we’ve built on previous pages.
Table of contents
- Self-hosting quickstart: Docker, domains, and DNS (look below!)
- A docker-compose tutorial
- Using docker-compose to add web apps
- Self-hosting administration
- Self-hosting Nextcloud with Docker
- Why is self-hosting Nextcloud a good idea?
- What to add to your docker-compose.yml file
- Create your admin user and setup your database
Hi there! This is a blog post from the people behind SSD Nodes.
We’re the first honest-value VPS provider. Instead of inflating costs, our engineers developed a lean infrastructure that lets us offer up to 10x more RAM per dollar than the competition. Ready to learn more about what you get from an honest VPS provider? Here’s a hint: Our 24GB RAM Standard VPS is only $9.99/mo.
My journey into self-hosting began with a simple problem: I wanted to be able to synchronize files between my various machines, a la Dropbox, but I didn’t want to pay yet another monthly SaaS subscription. My VPS-as-VPN experiment wasn’t going well, and so I decided to give my relatively unused VPS some new life.
That’s the great thing about self-hosting with a VPS—you can always pivot how you’re using it, or add something new on top of what you’re already doing (as long as you don’t run out of resources!). That’s a great way to get a return on your VPS investment.
On top of that, self-hosting Nextcloud offers many other benefits. I like the ability to completely control my data instead of handing it off to Dropbox or another cloud drive service like Google One (once Google Drive) or Microsoft’s OneDrive.
I don’t use many of Nextcloud’s features beyond simple file synchronization, but you can also migrate away entirely from Google if you’d like, as it offers everything from contacts, chats, calendars, photo organization, bookmarks, TODOs, and more.
To delpoy a self-hosted Nextcloud server, you need to add three new services to your existing
docker-compose.yml file. If you landed here first and you don’t have one, be sure to start at the beginning of this handbook for more details.
Here are the three services in full:
nextcloud: image: nextcloud:apache container_name: nextcloud restart: unless-stopped environment: - VIRTUAL_HOST=SUBDOMAIN.DOMAIN.TLD - LETSENCRYPT_HOST=SUBDOMAIN.DOMAIN.TLD - [email protected] - PGID=999 - PUID=1000 volumes: - ./nextcloud:/var/www/html ports: - "666:80" networks: - proxy-tier - default depends_on: - "db" db: image: mariadb container_name: db restart: always environment: MYSQL_ROOT_PASSWORD: PASSWORD MYSQL_PASSWORD: PASSWORD MYSQL_DATABASE: nextcloud MYSQL_USER: nextcloud volumes: - ./db:/var/lib/mysql ports: - "3306:3306"
As with previous examples, begin by replacing
[email protected] with your own domain details and email. You might also want to change the
container_name field, depending on your needs. I also highly recommend changing the
MYSQL_PASSWORD fields as well.
Once you’ve added these items, you should be able to deploy Nextcloud via a
docker-compose up -d. After pulling images and deploying new containers, your Nextcloud server should be up and running on the subdomain of your choice! Hop over there on your browser of choice to see the admin account creation screen.
First, choose a username and (secure) password for your administrator account.
Then click the
Storage & database link to see options for configuring a database, and then click on the
MySQL/MariaDB button. You’ll need to enter a few pieces of information based on your
docker-compose.yml file. If you left the default environment variables in place, you’d use the following:
nextcloud PASSWORD nextcloud db
Hit the button to move forward, and after a few moments, you’ll be dropped into the Nextcloud web interface! You can now configure Nextcloud’s desktop/mobile apps to synchronize files to your self-hosted Dropbox alternative. Pretty sweet, no?
Table of contents
Like what you saw? Subscribe to our weekly newsletter.