Self-hosting with Docker: The definitive handbook

Self-hosting guide

This self-hosting handbook's goal is to teach you how to use a virtual private server (VPS) to self-host a variety of mostly free (and sometimes paid) websites, applications, and services.

If you're new to self-hosting, scroll down for an introduction. If you're ready to get started, you can hop straight down into the Self-hosting quickstart: Docker, domains, and DNS section.

In this handbook, I'll show you how to set up your VPS to use Docker containers, configure your domain and its DNS communicate with your VPS, build a "reverse proxy" with Nginx, encrypt everything with SSL certificates from Let's Encrypt, and use docker-compose to create an entire self-hosted infrastructure that's as extensive as you want.

Table of contents

  1. Self-hosting quickstart: Docker, domains, and DNS (look below!)
  2. A docker-compose tutorial
  3. Using docker-compose to add web apps
  4. Self-hosting administration
  5. Self-hosting Nextcloud with Docker

What's the BEST DEAL in cloud hosting?

Develop at hyperspeed with a Performance VPS from SSD Nodes. We DOUBLED the amount of blazing-fast NVMe storage on our most popular plan and beefed up the CPU offering on these plans. There's nothing else like it on the market, at least not at these prices.

Score a 16GB Performance VPS with 160GB of NVMe storage for just $99/year for a limited time!

Get limited-time deals!⚡


Self-hosting is an old term that's been around computing for a long time. In recent years, given the acceleration of Software as a Service (SaaS) web applications, we've seen the interest around self-hosting grow significantly.

You are self-hosting when you put a web application on a VPS you own instead of relying on another business to host the application for you.

For a comprehensive explanation of self-hosting, visit What the Heck is Self-Hosting? A Guide to ‘Owning’ Your Webapps.

I still don't know what self-hosting is Expand

You can visit and have a blog in a matter of minutes. is hosting your blog for you, as they control the web app, the server, and the data.

Or, you can visit and download a copy of the WordPress source code for yourself. You can install WordPress on top of a web server and self-host your blog. In this case, you control the web app, the server, and the data.

Today, you can self-host far more than blogs. Be sure to check out our ultimate guide to self-hosted alternatives for dozens of ideas.

About SSD Nodes

We're the first honest-value cloud computing platform. Our 16GB RAM VPS, running on a KVM platform, is only $[price]/mo when billed annually. That's around 90% lower than Digital Ocean, Linode, or Vultr, with all the same power and resiliency.

Spin up a server →

Continue to a comprehensive self-hosting handbook

You can find the first steps to this self-hosting handbook below. The other pages will be published and linked to over the course of a few weeks, beginning on June 19, 2018.

Be sure to bookmark this guide and follow us on Twitter to get updates and check back when new sections are relevant to your self-hosting needs.

Self-hosting quickstart: Docker, domains, and DNS

This is the first page of an in-progress handbook.


  • Let's make this easy. You need a VPS with an operating system/kernel on which you can install Docker. Once we're working primarily with Docker/docker-compose, all the steps are independent of your operating system.
  • You also need a registered domain name with a registrar that allows you to change DNS settings.

What's the BEST DEAL in cloud hosting?

Develop at hyperspeed with a Performance VPS from SSD Nodes. We DOUBLED the amount of blazing-fast NVMe storage on our most popular plan and beefed up the CPU offering on these plans. There's nothing else like it on the market, at least not at these prices.

Score a 16GB Performance VPS with 160GB of NVMe storage for just $99/year for a limited time!

Get limited-time deals!⚡

Install Docker and docker-compose

Installing Docker used to be a more involved process, but the maintainers now offer an installation script you can download and execute in a single command. Type in the following into your VPS, and you'll have a functional Docker installation in a matter of minutes.

$ sudo curl -sS | sh

The script checks your operating system, downloads and installs package repositories, installs Docker itself alongside any dependencies, and starts the Docker service.

Let's quickly hammer out a few customizations that will make using Docker a little easier. We'll start the Docker service and allow running Docker as a non-sudo user. See our getting started with Docker tutorial for details.

$ sudo systemctl enable docker
$ sudo groupadd docker
$ sudo usermod -aG docker $USER

Log out of your VPS and back in again, and you'll be able to run docker commands with your normal user.

To install docker-compose, type in the following commands to download the latest version of docker-compose and set the executable flag so that you can run it from the terminal on your VPS.

$ sudo -i
# curl -L`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose

Now what you have the necessary software installed on your VPS, it's time to take a step back and

Register your domain(s)

Self-hosting works best if you have a domain name at which you, or others, can access your services and content. Without a domain name, the only method of accessing your VPS will be via IP address and port numbers. No one wants to type into their browser's address bar.

The registrar you choose to register your domain is entirely up to you, but two popular choices are Namecheap and Namesilo. You can also register a domain via your SSD Nodes dashboard.

No matter which registrar you choose, make sure that you can change both nameserver and DNS settings once you register your domain.

From this point on, I'll refer to your domain as DOMAIN.TLD or SUBDOMAIN.DOMAIN.TLD. For example, this blog is at blog.ssdnodes.comblog is the SUBDOMAIN, ssdnodes is the DOMAIN, and com is the TLD.

Create a Cloudflare account

This step is optional but recommended. If you'd prefer not using Cloudflare to manage your DNS, you can skip down to the Set up your DNS step and adopt the recommendations to your registrar's DNS dashboard.

If you don't already have a Cloudflare account, go ahead and create one, choosing the free plan as you go through the steps. It will be more than enough for self-hosting services that you, friends, or family will use on a regular basis.

When prompted to add a site to your new Cloudflare account, enter in the domain name you registered in the previous step.

Self-hosting guide: Add a site to Cloudflare

You'll then be asked to change your domain's nameservers, as seen in the screenshot below.

Self-hosting guide: Cloudflare nameservers

In a new tab, open up your registrar's dashboard and navigate to the nameserver configuration area. Replace the existing nameservers with the ones Cloudflare has assigned to your site. Don't use the nameservers in the above image, as Cloudflare will likely assign different servers to you.

This is what it looks like on Namecheap, my current registrar of choice:

Self-hosting guide: Changing nameservers on Namecheap

Once Cloudflare has added your domain/site to its infrastructure, nameserver propagation begins and can take some time to go into effect. Give yourself a break from the computer and take your dog on a walk. Or take yourself on a walk. Your heart will thank you either way.

Set up your DNS via Cloudflare

In this step, we'll set up our DNS so that the domain you registered will send traffic toward your server, along with any subdomains you want to use. If you're using another DNS service, follow the directions on the registrar's DNS settings page.

Click on the DNS tab in the Cloudflare dashboard and look at the first DNS record in the table. An A record for the name DOMAIN.TLD will have the value of points to IP_ADDRESS. That IP address probably leads to a parking page that your registrar puts up by default. Replace the IP address with that of your VPS.

Under the Status column, you'll see an orange cloud icon. Click it, and it will turn gray, disabling Cloudflare's HTTP proxy/CDN, but keeping the DNS settings in place. You must disable the HTTP proxy for your reverse proxy to work properly. Don't be like me and spend days trying to figure out why you're getting redirect loops.

Why can't I use Cloudflare's CDN? Expand

There is an issue with nginx-proxy and Cloudflare in which Cloudflare and the server are unable to coordinate whether to communicate over HTTP or HTTPS. Because of this miscommunication, the server sends HTTPS traffic back while Cloudflare is expecting HTTP traffic. Cloudflare then continues to re-send the same request, which results in a redirect loop.

Disabling the HTTP proxy is one solution. You can also try editing the Nginx configuration, but I have not yet tested that solution.

I don't think the CDN offers much of a benefit for most self-hosted applications, and thus I'm okay with it being disabled. I'll update this step when I can figure out a solution that allows you to use the Cloudflare CDN.

Try out your domain for the first time

Wait a few minutes for the DNS changes to go into effect, and give your new DNS a try with SSH.

Before, you probably logged into your VPS using its IP address.

$ ssh [email protected]_ADDRSESS

Now, you can replace the IP address with your domain.

$ ssh [email protected]

That's pretty neat! No more trying to remember your IP address every time you need to log in.

Add your subdomains

Now is an excellent opportunity to configure Cloudflare's DNS settings with any other subdomains you would like to set up.

Let's go ahead and add a docker subdomain, as one of the first services we'll add to our self-hosted stack is Portainer, an excellent management dashboard for Docker containers.

In the input area just above the table of DNS records, select an A record from the drop-down (it should be selected by default), type docker into the Name input, and then your VPS' IP address into the IPv4 address field. Leave Automatic TTL enabled, and click the cloud icon so that it turns gray. You can then click Add Record to enable it.

Once we have our reverse proxy and Portainer running, you'll be able to access it via docker.DOMAIN.TLD.

Follow the same process for any other subdomains you know you're going to use in the future. If you're unsure, don't worry—you can add more DNS records at any time.

Bookmark this guide and follow us on Twitter or Mastodon to get updates. Or, you can subscribe to the weekly Serverwise newsletter, where I’ll let you know as soon as this guide expands.