<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Docker on Techobyte Blog</title>
    <link>/tags/docker/</link>
    <description>Recent content in Docker on Techobyte Blog</description>
    <generator>Hugo</generator>
    <language>en-US</language>
    <lastBuildDate>Sun, 02 Aug 2026 00:00:00 -0400</lastBuildDate>
    <atom:link href="/tags/docker/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>200 Docker Compose Templates</title>
      <link>/posts/200-docker-compose-templates/</link>
      <pubDate>Sun, 02 Aug 2026 00:00:00 -0400</pubDate>
      <guid>/posts/200-docker-compose-templates/</guid>
      <description>&lt;p&gt;&lt;img alt=&#34;200 templates&#34; loading=&#34;lazy&#34; src=&#34;/posts/200-docker-compose-templates/200-compose-templates.png#center&#34;&gt;&lt;/p&gt;
&lt;p&gt;I have been maintaining a git monorepo named &lt;a href=&#34;https://github.com/redjax/docker_templates&#34;&gt;&lt;code&gt;docker_templates&lt;/code&gt;&lt;/a&gt; since sometime in 2023, and I recently added my 200th template &lt;a href=&#34;https://github.com/redjax/docker_templates/tree/7c112b7222d81330c0310ec851c7b512f48347e6&#34;&gt;(commit &lt;code&gt;7c112b7&lt;/code&gt;)&lt;/a&gt;! I thought back to 2015, when I started learning Docker and Docker Compose, and how transformative containers have been in the way I use my machines. There is something very satisfying about describing a runtime you want to work with and encapsulating everything you need to run an app or service the same way each time you run it, on any machine. In reality, there are some edge cases, but it&amp;rsquo;s a beautiful dream.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><img alt="200 templates" loading="lazy" src="/posts/200-docker-compose-templates/200-compose-templates.png#center"></p>
<p>I have been maintaining a git monorepo named <a href="https://github.com/redjax/docker_templates"><code>docker_templates</code></a> since sometime in 2023, and I recently added my 200th template <a href="https://github.com/redjax/docker_templates/tree/7c112b7222d81330c0310ec851c7b512f48347e6">(commit <code>7c112b7</code>)</a>! I thought back to 2015, when I started learning Docker and Docker Compose, and how transformative containers have been in the way I use my machines. There is something very satisfying about describing a runtime you want to work with and encapsulating everything you need to run an app or service the same way each time you run it, on any machine. In reality, there are some edge cases, but it&rsquo;s a beautiful dream.</p>
<p>The structure of the <code>docker_templates</code> repository continues to evolve, but it&rsquo;s also come a long way from where it started. I use this repository in some way almost every day. It is the heart of my homelab, and is where I keep references for pretty much every service I&rsquo;ve stood up on one of my machines. I will now indulge my nostalgia by showing you how the repository has grown over time, how I use it, and share a few of my most useful/favorite containers.</p>
<h2 id="the-beginning-disparate-directories-with-docker-compose-files">The Beginning: Disparate Directories with Docker Compose Files</h2>
<p>I learned to write Dockerfiles to containerize my Python programs, and quickly picked up Docker Compose so I could run things like a Postgres database or Redis message queue (for Python&rsquo;s Celery scheduling library). Eventually, I started to find programs and apps I wanted to host myself, like a media server, document hosting, monitoring/alerting services, etc.</p>
<p>For years, whenever I wanted to try a new service, I would create a directory for it, write a <code>docker-compose.yml</code> file, and run it. I was hardcoding non-secret values in my Compose files for a long time (using a <code>.env</code> or environment variables to pass secrets to the template). Sometimes I would initialize a git repository and push the stack to Github, other times the directory would just sit on one of my machines wherever I originally put it. The mental overhead of deciding if the new service I wanted to try was worthy of initializing as a git repository, making sure my <code>.gitignore</code> would keep my <code>.env</code> file out of git history and ignore host volume mounts, and deciding where to put the code on my machine started to slow me down and made me hesitant to really invest time into the templates I was creating. I ended up with a lot of different repositories and realized this was not sustainable long-term.</p>
<h2 id="the-monorepo">The Monorepo</h2>
<p>At some point in 2023, I decided to start a new git monorepo to store all of the services I ran in Docker Compose. I created my <a href="https://github.com/redjax/docker_templates"><code>docker_templates</code> repository</a>, and one-by-one started copying Compose files I had written into the repository. Pulling everything into one place allowed me to do some cleanup, and made it much easier to start new templates. Whenever I wanted to run a new service, I would clone the repository into a path in my <code>~/git/</code> directory, name it after the service, and create the <code>docker-compose.yml</code> file alongside all my other templates in a branch named after the service. Each service existed in an immediate child of the <code>templates/</code> directory, and over time that path became difficult to sort through.</p>
<p>This worked great for a while, but as I added more and more containers, and thought about all of the templates I planned to add in the future, I realized the structure of the <code>templates/</code> directory would need to change, and the multiplicative git cloning would end up being a storage problem in the long term. I decided to overhaul the organization of templates in the repository, and write scripts to help me manage the complexity and initialize new templates in a standardized way.</p>
<h3 id="cookiecutter-templates">Cookiecutter Templates</h3>
<p>When I would start new service templates, I would usually go to a previous template and copy the <code>docker-compose.yml</code> and <code>README.md</code> files into the new path and rewrite them for the new service. I realized I wanted to standardize the way I initialized new template directories. I was familiar with Jinja2 templating from writing Python programs, and had used <a href="https://github.com/cookiecutter/cookiecutter">Cookiecutter</a> in the past to create templated Python project repositories. So I created a <a href="https://github.com/redjax/docker_templates/tree/main/templates/_cookiecutter/docker-template">standardized Docker Compose service template directory</a>, with a common starting point for all future templates, and a <a href="https://github.com/redjax/docker_templates/blob/main/scripts/new_template.py">Python script</a> to guide the user through initializing a new template. I am definitely yada-yada-ing a lot of steps I took to get to this point, but after a few iterations, I settled on the template I have been using for the majority of the time this repository has existed.</p>
<p>Each new repository created from the Cookiecutter template starts with the same files:</p>
<ul>
<li><code>.docker-compose.template</code>: An empty marker file for some of the maintenance scripts&hellip;I&rsquo;ll explain more later.</li>
<li><code>.env.example</code>: I parameterize my <code>compose.yml</code> files, and provide an example <code>.env</code> file with the defaults for each service.
<ul>
<li>The user is instructed to copy <code>.env.example</code> to <code>.env</code> (which is ignored in the <code>.gitignore</code> for the whole repository) to configure the running stack.</li>
</ul>
</li>
<li><code>.gitignore</code>: Template-local ignore pattern overrides.</li>
<li><code>README.md</code>: The <code>new_template.py</code> script prompts the user for a title, summary, and optional description, and populates the README file with the user&rsquo;s inputs.</li>
<li><code>compose.yml</code>: The Python script generates a Docker Compose template file with the basic shape defined, so I can just start writing service definitions.</li>
</ul>
<h3 id="path-markers">Path Markers</h3>
<p>Once the template business was all sorted out, I decided to create <a href="https://github.com/redjax/docker_templates/tree/main/templates">subdirectories under the <code>templates/</code> path</a> that would serve as &ldquo;categories.&rdquo; I put my Postgres, Mariadb, Redis, and InnoDB containers under the <code>database/</code> path, my Plex and Jellyfin servers under <code>media/</code>, Ntfy and Gotify containers under <code>notifications/</code>, and so on. Splitting things up this way made it easier to browse through the containers on the web, and helped to kept the stacks logically sorted by archetype.</p>
<p>In each &ldquo;category&rdquo; directory, I created an empty <code>.category</code> file marker. I used the <code>.category</code> and <code>.docker-compose.template</code> files to write scripts that managed some of the complexity in the repository. For example, the <a href="https://github.com/redjax/docker_templates/blob/main/scripts/count_templates.py"><code>count_templates.py</code> script</a> finds all of the <code>.docker-compose.template</code> files in the repository and returns a count, which I use to update the templates count in the <a href="https://github.com/redjax/docker_templates/blob/main/README.md">repository&rsquo;s README.md</a>. I wrote a <a href="https://github.com/redjax/docker_templates/blob/main/.github/workflows/update-templates-count.yml">Github workflow</a> to run the script on a schedule, and if the count is different from what&rsquo;s in the README.md, it updates the <code>Templates:\s*\d+</code> pattern with the new count.</p>
<h3 id="repository-map">Repository Map</h3>
<p>I also created a <a href="https://github.com/redjax/docker_templates/tree/main/map">repository &ldquo;map&rdquo;</a>, a README.md file that finds all of the <code>.category</code> markers and creates a file tree from <a href="https://github.com/redjax/docker_templates/blob/main/map/_template/README.md.j2">a README.md Jinja template</a>, and a <a href="https://github.com/redjax/docker_templates/blob/main/scripts/update_repo_map.py">script to update the map README when new categories are created</a>. The <a href="https://github.com/redjax/docker_templates/blob/main/.github/workflows/update-repo-map.yml"><code>update-repo-map.yml</code> Github workflow</a> also runs nightly to keep this file updated with the latest templates.</p>
<h3 id="repository-metadata">Repository Metadata</h3>
<p>The scripts that update my README files also write data to the <a href="https://github.com/redjax/docker_templates/tree/main/metadata"><code>metadata/</code> directory</a>. This can act as a sort of read-only API using cURL requests. For example, the repository map uses the <a href="https://github.com/redjax/docker_templates/blob/main/metadata/categories.json"><code>categories.json</code> file</a> to populate the tree, and all <code>.category</code> and <code>.docker-compose.template</code> markers are in <a href="https://github.com/redjax/docker_templates/blob/main/metadata/beacons.json"><code>beacons.json</code></a>. I started calling the marker files &ldquo;beacons&rdquo; at one point, and it just kind of stuck.</p>
<p>The metadata files are only really used for rendering README templates, but I have plans for things like a frontend webUI to explore the repository&rsquo;s templates, and a Go CLI for downloading and using individual templates.</p>
<h2 id="git-sparse-checkouts">Git Sparse Checkouts</h2>
<p>I mentioned earlier that I was cloning the whole repository each time I wanted to run a template I had in <code>docker_templates</code>. This quickly became a problem as the size of the repository grew. The repository is currently 10MB in size (mostly due to image files and some larger files in history that I&rsquo;ll clean up at some point), so each time I cloned the repository, I added 10MB of disk usage.</p>
<p>I discovered <a href="https://git-scm.com/docs/git-sparse-checkout">git sparse checkouts</a> when I searched for a solution to this problem. A sparse checkout is a git operation that allows you to checkout only a subset of the files in a repository. When I&rsquo;m running a Docker Compose template, I don&rsquo;t need to pull the <code>src/img</code> directory, with the <code>.png</code> I render in the main README.md; I can pull just the files in the Compose template I wish to run.</p>
<p>In practice, most of my sparse checkouts are ~5% of the total size of the repository, which is about the same amount of size they would take as separate git repositories. It adds a few steps to the initial checkout process, but it makes the clone a focused copy with only as much as I need to run.</p>
<p>As an example, if I want to run a <a href="https://github.com/redjax/docker_templates/tree/main/templates/monitoring_alerting/docker_zabbix">Zabbix server container</a>, I would run the following commands:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">$&gt; git clone --no-checkout https://github.com/redjax/docker_templates docker_zabbix
</span></span><span class="line"><span class="cl">$&gt; <span class="nb">cd</span> docker_zabbix
</span></span><span class="line"><span class="cl"><span class="c1">## Initialize sparse checkout</span>
</span></span><span class="line"><span class="cl">$&gt; git sparse-checkout init --cone
</span></span><span class="line"><span class="cl"><span class="c1">## Tell git which paths to checkout</span>
</span></span><span class="line"><span class="cl">$&gt; git sparse-checkout <span class="nb">set</span> templates/monitoring_alerting/docker_zabbix
</span></span><span class="line"><span class="cl"><span class="c1">## Checkout the main branch, or a working branch for the zabbix server</span>
</span></span><span class="line"><span class="cl">$&gt; git checkout feat/some-zabbix-feature
</span></span></code></pre></td></tr></table>
</div>
</div><p>This would create a directory named <code>docker_zabbix/</code>, which would have all of the files in the root path, and a single directory named <code>templates/</code>, with <code>monitoring_alerting/docker_zabbix</code>. All of the other containers still exist in the remote, but sparse checkouts let me focus on a single template.</p>
<p><a href="https://git-scm.com/docs/git-worktree">Git Worktrees</a> were not a thing when I started using sparse checkouts. An alternative to the sparse checkout method described above is cloning the whole <code>docker_templates</code> repository once, then creating worktrees for all of the services you want to run. A worktree exists in a separate path on the machine like a sparse clone would. They share the same git object database, meaning paths and objects are deduplicated, which saves space on the disk.</p>
<p>To create a Zabbix server container using a worktree, you would clone the whole repository once, <code>cd</code> into it, then create worktrees for each service you want to run. The limitation here is that each worktree checks out a branch, and only that worktree can use that branch. So, the original repository clone stays on the <code>main</code> branch, and each worktree must have its own branch, even if I&rsquo;m not making any changes on that service.</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">$&gt; git clone https://github.com/redjax/docker_templates
</span></span><span class="line"><span class="cl">$&gt; <span class="nb">cd</span> docker_templates
</span></span><span class="line"><span class="cl">$&gt; git worktree add -b feat/zabbix-server ../docker_zabbix
</span></span><span class="line"><span class="cl">$&gt; <span class="nb">cd</span> ../docker_zabbix
</span></span></code></pre></td></tr></table>
</div>
</div><p>I have continued to use sparse checkouts because I often checkout a service and just run it on the <code>main</code> branch until I have updates or fixes to apply, and this flow does not work with worktrees.</p>
<h2 id="how-i-use-it">How I Use It</h2>
<p>I have a full clone of this repository on a few of my machines, which I don&rsquo;t modify after cloning except to create new templates. When I want to try a new service, I <code>cd</code> into the local clone, create a branch for the new service, and run the <code>new_template.py</code> script, which prompts me for a template name, category, summary, and optional description. I usually add a link of some sort in the summary, i.e. a Github repository or documentation URL.</p>
<p>I commit the files as the initial starting point for that repository and push the branch up to git. Then I do a sparse clone and checkout the new service&rsquo;s branch, and I get to work building the <code>compose.yml</code> and <code>.env.example</code>. I usually create host volume mounts in the git path, although a better practice would be storing Docker files in another path, like <code>/opt/docker_data</code> or something. The things we wished we learned sooner&hellip;</p>
<p>Eventually, when the template is in working condition, I merge the branch into <code>main</code>. As I make changes to the template, I create <code>feat/</code> and <code>fix/</code> branches, which also get merged into main. The idea/goal is to be running my services off the stable <code>main</code> branch as often as possible.</p>
<h3 id="favorite-containers">Favorite Containers</h3>
<p>With some containers, I get them into working order, then bring the stack down and forget about it. I still like having the reference file in my repository, but I might not actively run the container. If it&rsquo;s in the <code>main</code> branch, it means I got it running at one point and it&rsquo;s ready to run again.</p>
<p>But there are some templates I am constantly running, or re-using on different machines.</p>
<ul>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/networking/docker_pangolin"><code>docker_pangolin</code></a>: One of the most important services in my stack! <a href="https://github.com/fosrl/pangolin">Pangolin</a> is my reverse HTTP proxy.
<ul>
<li>I have Pangolin running on a VPS I rent.</li>
<li>I route my domain name through Cloudflare, and have Cloudflare pointed at the VPS.</li>
<li>In Pangolin, I create subdomain routes to services I want to expose to the Internet, and route the traffic over a private tunnel.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/networking/docker_adguard"><code>docker_adguard</code></a>: I run an <a href="https://github.com/redjax/docker_templates/tree/main/templates/networking/docker_adguard">AdGuard Home container</a> for ad blocking on my entire LAN.
<ul>
<li>My router uses the AdGuard container as its DNS server.</li>
<li>I create records for my important machines, so I can resolve <code>machine-name.home</code> anywhere on my network instead of remembering IP addresses.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/networking/docker_netbird"><code>docker_netbird</code></a>: I use <a href="https://netbird.io/">Netbird</a> to run a private network, similar to how many people use <a href="https://tailscale.com/">Tailscale</a>.
<ul>
<li>I use access policies to allow or restrict traffic between devices, and to give my friends limited access to things like my media and game servers.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/documents/docker_paperless-ngx"><code>docker_paperless-ngx</code></a>: <a href="https://docs.paperless-ngx.com/">Paperless-ngx</a> is an incredibly useful document management system.
<ul>
<li>I upload my receipts, work documents for things like benefits packages and employee handbooks, PDFs, and airline tickets.</li>
<li>Daily backups to local and offsite storage prevent data loss (and I&rsquo;ve had to recover a few times; don&rsquo;t neglect your backups!).</li>
<li>Full-text search lets me find things quickly, and the tagging system lets me sort documents, with tags like <code>receipt</code>, <code>pets</code>, <code>house</code>, <code>vehicle</code>, etc.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/automation/docker_concourse_ci"><code>docker_concourse_ci</code></a>: I use <a href="https://concourse-ci.org/">Concourse CI</a> for some of my homelab automation pipelines.</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/automation/docker_semaphore"><code>docker_semaphore</code></a>: <a href="https://semaphoreui.com/">Semaphore</a> lets me run my <a href="https://gitlab.com/redjax/ansible-roles">Ansible roles</a> and <a href="https://gitlab.com/redjax/ansible-playbooks">playbooks</a>, as well as scheduled Bash scripts and <a href="https://github.com/redjax/Terraform">Terraform</a> from a convenient webUI.</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/backup/docker_gickup"><code>docker_gickup</code></a>: <a href="https://github.com/cooperspencer/gickup">Gickup</a> is a useful utility for backing up and mirroring git repositories.
<ul>
<li>I keep a config file with all of my most important/valuable repositories, and Gickup runs on a Raspberry Pi, pulling my changes to a local drive and mirroring some to a self-hosted Git instance.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/database"><code>database</code></a>: A collection of database templates.
<ul>
<li>I frequently use <a href="https://github.com/redjax/docker_templates/tree/main/templates/database/docker_postgresql">Postgres</a> and <a href="https://github.com/redjax/docker_templates/tree/main/templates/database/docker_redis">Redis</a> in my homelab, and I use <a href="https://github.com/redjax/docker_templates/tree/main/templates/database/docker_influxdb">InfluxDB</a> for some of my time-series data like weather readings.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/bookmarking/docker_linkwarden"><code>docker_linkwarden</code></a>: <a href="https://linkwarden.app/">Linkwarden</a> is a bookmarking/read-it-later app.
<ul>
<li>I imported all of my browser bookmarks when I set it up initially, and I frequently save new links I come across on the web.</li>
<li>I can export Linkwarden&rsquo;s saved links as a <code>bookmarks.html</code> file to synchronize back to my browser.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/code_forges/docker_forgejo"><code>docker_forgejo</code></a>: <a href="https://forgejo.org/">Forgejo</a> is a self-hosted Git forge, reminiscent of 2015-2018 Github.
<ul>
<li>The Forgejo Actions platform is semi-compatible with Github actions, and Forgejo&rsquo;s pipelines are very similar in syntax.</li>
<li>I host a private/local-only Git forge for some of my more sensitive repositories that I do not want to expose to the Internet.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/code_forges/docker_opengist"><code>docker_opengist</code></a>: I am a big fan of Github Gists, and discovered <a href="https://opengist.io/">OpenGist</a>, which is basically the self-hosted version.
<ul>
<li>I put a lot of code snippets, scripts, and reference files here, and occasionally I will expand a gist into an Obsidian note, or a post on this blog!</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/dav"><code>dav</code></a>: I self-host my contacts and calendars, and synchronize them with my email client.
<ul>
<li>I primarily use <a href="https://github.com/redjax/docker_templates/tree/main/templates/dav/docker_radicale">Radicale</a>, but have recently been test driving <a href="https://github.com/redjax/docker_templates/tree/main/templates/dav/docker_davis">Davis</a> and am liking it a lot.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/games"><code>games</code></a>: I host a bunch of game servers for my friends and me. We connect over a private network I host to play.</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/monitoring_alerting"><code>monitoring_alerting</code></a>: I have tried many different monitoring/alerting solutions, and have kept a template for each one in this path.
<ul>
<li>I used <a href="https://github.com/redjax/docker_templates/tree/main/templates/monitoring_alerting/docker_zabbix">Zabbix</a> for a while, but more recently I have used <a href="https://github.com/redjax/docker_templates/tree/main/templates/monitoring_alerting/docker_beszel">Beszel</a> for server metric monitoring, <a href="https://github.com/redjax/docker_templates/tree/main/templates/monitoring_alerting/docker_uptime-kuma">Uptime Kuma</a> for uptime checks, <a href="https://github.com/redjax/docker_templates/tree/main/templates/monitoring_alerting/docker_happydomain">happyDomain</a> to track and monitor my domains and DNS records, and <a href="https://github.com/redjax/docker_templates/tree/main/templates/monitoring_alerting/docker_ntopng">NtopNG</a> for local network monitoring.</li>
<li>I run Uptime Kuma from a VPS so it can watch my homelab for outages.</li>
</ul>
</li>
<li><a href="https://github.com/redjax/docker_templates/tree/main/templates/notifications/docker_ntfy"><code>docker_ntfy</code></a>/<a href="https://github.com/redjax/docker_templates/tree/main/templates/notifications/docker_gotify"><code>docker_gotify</code></a>: My own self-hosted push notification servers.
<ul>
<li>Ntfy and Gotify work very similarly, and I have been test driving both for a while.</li>
<li>I can&rsquo;t decide which one I prefer, and I don&rsquo;t see much harm in using both.</li>
<li>I&rsquo;ve recently added <a href="https://github.com/redjax/docker_templates/tree/main/templates/notifications/docker_apprise">Apprise</a> into the mix, which lets me send notifications to both services.</li>
</ul>
</li>
</ul>
]]></content:encoded>
    </item>
  </channel>
</rss>
