{"id":2950,"date":"2018-08-21T07:00:12","date_gmt":"2018-08-21T07:00:12","guid":{"rendered":"https:\/\/blog.ssdnodes.com\/blog\/?p=2461"},"modified":"2025-05-18T19:54:54","modified_gmt":"2025-05-18T19:54:54","slug":"self-hosting-nextcloud","status":"publish","type":"post","link":"https:\/\/www.ssdnodes.com\/blog\/self-hosting-nextcloud\/","title":{"rendered":"Self-Hosting Nextcloud with Docker: Self-hosting handbook"},"content":{"rendered":"<p>Welcome to the fifth page of a handbook on self-hosting. Begin <a href=\"https:\/\/www.ssdnodes.com\/blog\/self-hosting-handbook\/\">here<\/a>. Read the previous page <a href=\"https:\/\/www.ssdnodes.com\/blog\/self-hosting-administration\/\">here<\/a>. On this page, we\u2019ll cover self-hosting Nextcloud with Docker (<code>docker-compose<\/code>, more specifically) on top of the stack we\u2019ve built on previous pages.<\/p>\n<hr \/>\n<h2>Table of contents<\/h2>\n<ol>\n<li><a href=\"#self-hosting-quickstart-docker-domains-and-dns\">Self-hosting quickstart: Docker, domains, and DNS<\/a> (look below!)<\/li>\n<li><a href=\"https:\/\/www.ssdnodes.com\/blog\/self-hosting-handbook-a-docker-compose-tutorial\/\">A docker-compose tutorial<\/a><\/li>\n<li><a href=\"https:\/\/www.ssdnodes.com\/blog\/using-docker-compose-self-hosting\/\">Using docker-compose to add web apps<\/a><\/li>\n<li><a href=\"https:\/\/www.ssdnodes.com\/blog\/self-hosting-administration\/\">Self-hosting administration<\/a><\/li>\n<li><a href=\"https:\/\/www.ssdnodes.com\/blog\/self-hosting-nextcloud\/\">Self-hosting Nextcloud with Docker<\/a><\/li>\n<\/ol>\n<h2><a id=\"Topics_covered_on_this_page_6\"><\/a>Topics covered on this page<\/h2>\n<ol>\n<li><a href=\"#Why_is_selfhosting_Nextcloud_a_good_idea_13\">Why is self-hosting Nextcloud a good idea?<\/a><\/li>\n<li><a href=\"#What_to_add_to_your_dockercomposeyml_file_24\">What to add to your docker-compose.yml file<\/a><\/li>\n<li><a href=\"#Create_your_admin_user_and_setup_your_database_70\">Create your admin user and setup your database<\/a><\/li>\n<\/ol>\n<div class=\"cta-inline\"><\/div>\n<h2><a id=\"Why_is_selfhosting_Nextcloud_a_good_idea_13\"><\/a>Why is self-hosting Nextcloud a good idea?<\/h2>\n<p>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\u2019t want to pay yet another monthly SaaS subscription. My VPS-as-VPN experiment wasn\u2019t going well, and so I decided to give my relatively unused VPS some new life.<\/p>\n<p>That\u2019s the great thing about self-hosting with a VPS\u2014you can always pivot how you\u2019re using it, or add something new on top of what you\u2019re already doing (as long as you don\u2019t run out of resources!). That\u2019s a great way to <a href=\"https:\/\/www.ssdnodes.com\/blog\/5-simple-ways-to-get-a-return-on-your-vps-investment\/\">get a return on your VPS investment<\/a>.<\/p>\n<p>On top of that, self-hosting <a href=\"https:\/\/nextcloud.com\/\" target=\"_blank\" rel=\"noopener\">Nextcloud<\/a> 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\u2019s OneDrive.<\/p>\n<p>I don\u2019t use many of Nextcloud\u2019s features beyond simple file synchronization, but you can also migrate away entirely from Google if you\u2019d like, as it offers everything from contacts, chats, calendars, photo organization, bookmarks, TODOs, and more.<\/p>\n<h2><a id=\"What_to_add_to_your_dockercomposeyml_file_24\"><\/a>What to add to your docker-compose.yml file<\/h2>\n<p>To delpoy a self-hosted Nextcloud server, you need to add three new services to your existing <code>docker-compose.yml<\/code> file. If you landed here first and you don\u2019t have one, be sure to <a href=\"https:\/\/nextcloud.com\/\" target=\"_blank\" rel=\"noopener\">start at the beginning<\/a> of this handbook for more details.<\/p>\n<p>Here are the three services in full:<\/p>\n<pre><code>  nextcloud:\n    image: nextcloud:apache\n    container_name: nextcloud\n    restart: unless-stopped\n    environment:\n      - VIRTUAL_HOST=SUBDOMAIN.DOMAIN.TLD\n      - LETSENCRYPT_HOST=SUBDOMAIN.DOMAIN.TLD\n      - LETSENCRYPT_EMAIL=EMAIL@DOMAIN.TLD\n      - PGID=999\n      - PUID=1000\n    volumes:\n      - .\/nextcloud:\/var\/www\/html\n    ports:\n      - \"666:80\"\n    networks:\n      - proxy-tier\n      - default\n    depends_on:\n      - \"db\"\n\n  db:\n    image: mariadb\n    container_name: db\n    restart: always\n    environment:\n      MYSQL_ROOT_PASSWORD: PASSWORD\n      MYSQL_PASSWORD: PASSWORD\n      MYSQL_DATABASE: nextcloud\n      MYSQL_USER: nextcloud\n    volumes:\n      - .\/db:\/var\/lib\/mysql\n    ports:\n      - \"3306:3306\"\n<\/code><\/pre>\n<p>As with previous examples, begin by replacing <code>SUBDOMAIN.DOMAIN.TLD<\/code> and <a href=\"mailto:code&gt;EMAIL@DOMAIN.TLD&lt;\/code\">code>EMAIL@DOMAIN.TLD<\/code<\/a> with your own domain details and email. You might also want to change the <code>container_name<\/code> field, depending on your needs. I also highly recommend changing the <code>MYSQL_ROOT_PASSWORD<\/code> and <code>MYSQL_PASSWORD<\/code> fields as well.<\/p>\n<p>Once you\u2019ve added these items, you should be able to deploy Nextcloud via a <code>docker-compose up -d<\/code>. 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.<\/p>\n<h2><a id=\"Create_your_admin_user_and_setup_your_database_70\"><\/a>Create your admin user and setup your database<\/h2>\n<p>First, choose a username and (secure) password for your administrator account.<\/p>\n<p>Then click the <code>Storage &amp; database<\/code> link to see options for configuring a database, and then click on the <code>MySQL\/MariaDB<\/code> button. You\u2019ll need to enter a few pieces of information based on your <code>docker-compose.yml<\/code> file. If you left the default environment variables in place, you\u2019d use the following:<\/p>\n<pre><code>nextcloud\nPASSWORD\nnextcloud\ndb\n<\/code><\/pre>\n<p>Hit the button to move forward, and after a few moments, you\u2019ll be dropped into the Nextcloud web interface! You can now configure Nextcloud\u2019s desktop\/mobile apps to synchronize files to your self-hosted Dropbox alternative. Pretty sweet, no?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using Docker-Compose and the self-hosted stack from this guide, we can start self-hosting Nextcloud in minutes, and without all the sysadmin headaches.<\/p>\n","protected":false},"author":20,"featured_media":2963,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[18],"tags":[182,180],"class_list":["post-2950","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-docker","tag-nextcloud"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/2950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/comments?post=2950"}],"version-history":[{"count":3,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/2950\/revisions"}],"predecessor-version":[{"id":13076,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/2950\/revisions\/13076"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media\/2963"}],"wp:attachment":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media?parent=2950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/categories?post=2950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/tags?post=2950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}