How to self-host Docker apps
Self-hosted community projects are constantly growing in number, many of them operating under an open-source or fair-code license that saves you from paying costly subscriptions or usage-based fees.
<![CDATA[ <article> <p>Self-hosted community projects are constantly growing in number, many of them operating under an open-source or fair-code license that saves you from paying costly subscriptions or usage-based fees. </p><p>With <a href="https://www.techradar.com/pro/website-hosting/how-to-use-docker">Docker</a>, you can run any number of self-hosted applications on a standard web server or local workstation in completely separate environments using partitioned resources. Thanks to Docker Hub, you also gain access to a whole trove of community-maintained applications and projects that require very little effort to get working. </p><p>In this step-by-step guide, I’ll show you how to self-host Docker apps using any Linux-based workstation or <a href="https://www.techradar.com/vpn/best-vpn">VPS server</a>, all the way from installing Docker Engine to launching containerized applications with Docker Compose. We’ll even talk about some popular Docker apps to get you started, if you’re unsure what this setup can do for you. Let’s jump in. </p><h2 class="article-body__section" id="section-what-is-docker"><span>What is Docker?</span></h2><p>Docker is an open-source platform that packages your software into separate containers. </p><p>A container, in case you were wondering, is exactly what it sounds like — a walled-off section of your server or device that contains all the code, libraries, and settings associated with an application. Containers get their own separate resource allocations too, so you can be sure that an application isn’t drawing more from your system than it’s meant to. </p><p>Self-hosted applications rely on specific “dependencies,” like databases, programming languages, system tools, etc. That’s why most of them recommend installing through Docker, so that the dependencies installed for one application don’t break the dependencies of another application or service. Docker apps are completely isolated from each other so that they don’t pull from the same resources or interrupt one another during runtime. </p><p>You don’t need to learn everything about Docker just to self-host an app, but knowing some basics helps. Put simply, Docker Engine is the core platform that isolates your applications; images are the project libraries used to install an app or service, Docker Hub is a public library of images for apps you can run using Docker, and Docker Compose is an add-on that lets you launch multiple Docker containers at the same time for apps that are more complex.</p><h2 class="article-body__section" id="section-why-do-i-need-docker-compose"><span>Why do I need Docker Compose?</span></h2><p>Elaborating on that last point, most applications aren’t simple enough to run from a single container. They usually have a frontend component, a backend for administrators, as well as databases they use to store and retrieve information. </p><p>Instead of having to launch each Docker container separately by typing docker run into your Linux terminal or SSH every time you need to rerun the app, you can create a compose.yaml file to specify which containers and services need to run together. This is what Docker Compose helps you do. </p><p>Once you create a compose.yaml file, Docker Compose can help you run the entire application using a single command: </p><p><em>docker compose up</em></p><p>You can also use <em>docker compose stop</em> to pause your application temporarily and <em>docker compose down</em> to fully stop and clear the containers to prepare for another deployment. </p><h2 class="article-body__section" id="section-how-to-self-host-a-docker-app-step-by-step"><span>How to self-host a Docker app step-by-step</span></h2><p>Now that you know the basics, let’s walk through the exact process of self-hosting a containerized application with Docker Engine and Docker Compose. </p><h2 id="prerequisites">Prerequisites</h2><ul><li>A Linux-based home server or VPS running a recent version of Ubuntu or Debian</li><li>Root access to that server</li><li>An SSH client on your own computer (built into macOS, Linux, and modern Windows terminals) to interact with your server</li><li>Your server's IP address and SSH credentials</li></ul><h2 id="step-1-connect-to-your-server-over-ssh">Step 1: Connect to your server over SSH</h2><p>Access the terminal on your local macOS, Linux, or Windows device. We can log into your server from here by using your SSH credentials and server IP. Enter the following command to start: </p><p><em>ssh username@your-server-ip </em></p><p>Make sure to enter your SSH password when prompted. Now you’ve established a direct link from your current device to the server you’ll be installing Docker on. </p><p>Now update your server’s libraries and packages to the current version before proceeding. This way, you won’t run into any conflicts with the installation, and the latest security patches will be added immediately. </p><p><em>sudo apt update && sudo apt upgrade -y </em></p><figure class="van-image-figure inline-layout" data-bordeaux-image-check ><div class='image-full-width-wrapper'><div class='image-widthsetter' style="max-width:512px;"><p class="vanilla-image-block" style="padding-top:58.98%;"><img id="8p7GQTUQ4he6UkRcuQPxK8" name="unnamed (3)" alt="Docker screenshot" src="https://cdn.mos.cms.futurecdn.net/8p7GQTUQ4he6UkRcuQPxK8.png" mos="" align="middle" fullscreen="" width="512" height="302" attribution="" endorsement="" class="inline"></p></div></div><figcaption itemprop="caption description" class=" inline-layout"><span class="credit" itemprop="copyrightHolder">(Image credit: Docker)</span></figcaption></figure><h2 id="step-2-install-docker-engine">Step 2: Install Docker Engine</h2><p>You can pull the most recent version of Docker Engine from its official repository. Start by installing the necessary certificates and Docker’s GPG key: </p><pre class="line-numbers language-plaintext" language="plaintext" ><code>sudo apt install ca-certificates curlsudo install -m 0755 -d /etc/apt/keyringssudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.ascsudo chmod a+r /etc/apt/keyrings/docker.asc</code></pre><p>You also need to add the official Docker repo to your list of package sources: </p><pre class="line-numbers language-plaintext" language="plaintext" ><code>echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null</code></pre><p>Now update your packages and install Docker Engine with Compose: </p><pre class="line-numbers language-plaintext" language="plaintext" ><code>sudo apt updatesudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y</code></pre><p>After the process is complete, you can verify that Docker is installed correctly along with Compose with a quick version check: </p><pre class="line-numbers language-plaintext" language="plaintext" ><code>docker --versiondocker compose version</code></pre><p>If something went wrong during the installation, you’ll see a “command not found” error message in the terminal instead of the version numbers. That means you have to redo each step again in case you missed anything. </p><h2 id="step-3-set-up-the-project-directory">Step 3: Set up the project directory</h2><p>Now that Docker is installed, we can move on to preparing the project directory for your self-hosted app. First, I like to run a quick command to make sure Docker is accessible to all users, not just restricted to those with sudo or root privileges. Here’s the command to help you change those permissions: </p><p><em>sudo usermod -aG docker $USER</em></p><p>Log out, then restart your terminal to update the usage permissions. Now you can create the actual project directory and navigate into it: </p><p><em>mkdir ~/my-app && cd ~/my-app</em></p><figure class="van-image-figure inline-layout" data-bordeaux-image-check ><div class='image-full-width-wrapper'><div class='image-widthsetter' style="max-width:512px;"><p class="vanilla-image-block" style="padding-top:56.25%;"><img id="MzkYAuqqGP2JEpHrYkGqK8" name="unnamed (4)" alt="Docker screenshot" src="https://cdn.mos.cms.futurecdn.net/MzkYAuqqGP2JEpHrYkGqK8.png" mos="" align="middle" fullscreen="" width="512" height="288" attribution="" endorsement="" class="inline"></p></div></div><figcaption itemprop="caption description" class=" inline-layout"><span class="credit" itemprop="copyrightHolder">(Image credit: Docker)</span></figcaption></figure><h2 id="step-4-write-your-yaml-file">Step 4: Write your YAML file</h2><p>You’re ready to write the compose.yaml file into your project directory. Execute this command to launch into the Nano editor: </p><p><em>nano compose.yaml</em></p><p>Now paste in the contents of the compose.yaml as per your Docker app’s setup instructions. Typically, the compose.yaml file should include an image field for your project image, a container name, a volume field that maps out your project subfolders, and the specific port that the app will be launching in. Here’s an example of a YAML file for a status monitoring app called Uptime Kuma: </p><pre class="line-numbers language-plaintext" language="plaintext" ><code>services: uptime-kuma: image: louislam/uptime-kuma:1 container_name: uptime-kuma volumes: - ./uptime-kuma-data:/app/data ports: - "3001:3001" restart: unless-stopped</code></pre><p>Save the file and exit the editor. If this feels intimidating, don’t worry. You should find the specific instructions to create your YAML file in your Docker app’s setup instructions on Docker Hub or GitHub. </p><h2 id="step-5-launch-your-application">Step 5: Launch your application</h2><p>All that remains is to launch your Docker app using Compose. You can spin up all your Docker containers in any given project directory by running this single command: </p><p><em>docker compose up -d</em></p><p>Once the containers are up and running, which usually takes less than a minute, you can access your app by visiting this address from your web browser: http://your-server-ip:3001. Make sure to replace your-server-ip with the actual IP address of your home server or VPS, which looks something like “192.168.1.1” (IPv4) or “[2001:0db8:85a3:0000:0000:8a2e:0370:7334]” (IPv6).</p><figure class="van-image-figure inline-layout" data-bordeaux-image-check ><div class='image-full-width-wrapper'><div class='image-widthsetter' style="max-width:512px;"><p class="vanilla-image-block" style="padding-top:56.25%;"><img id="cgcxQKibR7sp7mEpgaaCM8" name="unnamed (5)" alt="Docker screenshot" src="https://cdn.mos.cms.futurecdn.net/cgcxQKibR7sp7mEpgaaCM8.png" mos="" align="middle" fullscreen="" width="512" height="288" attribution="" endorsement="" class="inline"></p></div></div><figcaption itemprop="caption description" class=" inline-layout"><span class="credit" itemprop="copyrightHolder">(Image credit: Docker)</span></figcaption></figure><h2 id="a-few-docker-apps-worth-trying">A few Docker apps worth trying</h2><ul><li><strong>Portainer:</strong> A visual interface for managing Docker containers without using your terminal or command line.</li><li><strong>Nextcloud:</strong> A privacy-first alternative to public cloud storage services like Google Drive.</li><li><strong>Pi-hole:</strong> A network-wide ad and tracker blocker. Works at the DNS level</li><li><strong>Jellyfin:</strong> A media server for streaming your own movies, shows, and music. It works similar to Netflix but with BYOD media management using your own media files.</li><li><strong>Vaultwarden:</strong> A self-hosted password manager that serves as an alternative to the Bitwarden API.</li><li><strong>AdGuard Home:</strong> Another popular DNS-based ad blocker with built-in encryption.</li><li><strong>Uptime Kuma:</strong> A simple status monitoring tool that alerts you when your self-hosted services or apps go down.</li></ul> </article> ]]>
Read the full article on TechRadar
Read Full Article →