<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Posts about Docker</title><link>https://chriswarrick.com/</link><atom:link href="https://chriswarrick.com/blog/tags/docker.xml" rel="self" type="application/rss+xml" /><description>A rarely updated blog, mostly about programming.</description><lastBuildDate>Fri, 06 Mar 2026 19:00:00 GMT</lastBuildDate><generator>https://github.com/Kwpolska/YetAnotherBlogGenerator</generator><item><title>Docker In WSL: A No-Frills Guide</title><dc:creator>Chris Warrick</dc:creator><link>https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/</link><pubDate>Wed, 04 Mar 2026 17:20:00 GMT</pubDate><guid>https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/</guid><description>Docker is great, but how do you run Linux containers on Windows? In WSL, of course. The Docker Desktop application is certainly an option, but it eats up a lot of RAM thanks to its Electron-based GUI. It also has an LLM chatbot (because of course it does, it’s 2026 after all). Just the Docker Desktop installer takes up 598 MB. What if you want something simpler and with less RAM consumption? WSL 2 makes it really straightforward to set up Docker with some basic Windows integration.
</description><content:encoded><![CDATA[<p>Docker is great, but how do you run Linux containers on Windows? In WSL, of course. The Docker Desktop application is certainly an option, but it eats up a lot of RAM thanks to its Electron-based GUI. It also has an LLM chatbot (because of course it does, it’s 2026 after all). Just the Docker Desktop installer takes up 598 MB. What if you want something simpler and with less RAM consumption? WSL 2 makes it really straightforward to set up Docker with some basic Windows integration.</p>



<p>(Also, Docker Desktop demands payment for enterprise use; if your company fits the enterprise criteria but cannot afford $16/developer/month, run.)</p>
<p><em>Console command conventions: <code>$</code> means Linux, <code>&gt;</code> means Windows (PowerShell).<br>Path conventions: <code>/</code> means Linux, <code>\</code> means Windows.</em></p>
<h2 id="linux-setup">Linux setup</h2>
<p>You need to have WSL and a distribution installed, and you must be using WSL 2. <a href="https://learn.microsoft.com/en-us/windows/wsl/install">Read the install docs if you need to do it.</a></p>
<p>➡️ Start by installing Docker in the usual way for your Linux distribution of choice. I’m using Ubuntu with <a href="https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository">the official Docker apt repository</a>. Make sure to <a href="https://docs.docker.com/engine/install/linux-postinstall">add yourself to the Docker group</a>.</p>
<p>➡️ Enable systemd support in WSL. Put those two lines into <code>/etc/wsl.conf</code>:</p>
<div class="highlight"><pre><span></span><span class="k">[boot]</span>
<span class="na">systemd</span><span class="o">=</span><span class="s">true</span>
</pre></div>

<p>You can do it like so (if you don’t have a <code>wsl.conf</code> file already):</p>
<div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">printf</span><span class="w"> </span><span class="s1">&#39;[boot]\nsystemd=true\n&#39;</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>sudo<span class="w"> </span>tee<span class="w"> </span>/etc/wsl.conf
</pre></div>

<p>➡️ Next, enable the systemd services:</p>
<div class="highlight"><pre><span></span><span class="gp">$ </span>sudo<span class="w"> </span>systemctl<span class="w"> </span><span class="nb">enable</span><span class="w"> </span>containerd.service
<span class="gp">$ </span>sudo<span class="w"> </span>systemctl<span class="w"> </span><span class="nb">enable</span><span class="w"> </span>docker.service
</pre></div>

<h2 id="exposing-docker-to-windows">Exposing Docker to Windows</h2>
<p>By default, Docker only listens on a Unix domain socket. To work with Docker from Windows, it needs to listen on a TCP socket. If you’re fine with using Docker only from the WSL terminal, and won’t run any Docker-compatible tools on the Windows side, you can basically stop reading here.</p>
<p>Adding a socket can be done in two ways: by adding command-line arguments, or by modifying <code>/etc/docker/daemon.json</code>. If your Docker systemd service is passing in arguments, you need to edit the service, and can’t do it using the <code>daemon.json</code> file. Let’s edit the service, as this is more likely to be what you need.</p>
<p>➡️ Run <code>sudo systemctl edit docker.service</code> and override the <code>ExecStart</code> command. The first <code>ExecStart=</code> line clears out the existing configuration defined in the system-provided service. The second line is the new command. To avoid breaking things, review the <code>ExecStart</code> command that is shown as the current content of your <code>docker.service</code>, and make sure you have both <code>-H</code> arguments as in my example below.</p>
<div class="code"><table class="codetable"><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-1"><code data-line-number="1"></code></a></td><td class="code"><code><a id="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-1" name="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-1"></a><span class="c1">### Editing /etc/systemd/system/docker.service.d/override.conf</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-2"><code data-line-number="2"></code></a></td><td class="code"><code><a id="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-2" name="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-2"></a><span class="c1">### Anything between here and the comment below will become the contents of the drop-in file</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-3"><code data-line-number="3"></code></a></td><td class="code"><code><a id="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-3" name="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-3"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-4"><code data-line-number="4"></code></a></td><td class="code"><code><a id="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-4" name="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-4"></a><span class="k">[Service]</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-5"><code data-line-number="5"></code></a></td><td class="code"><code><a id="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-5" name="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-5"></a><span class="na">ExecStart</span><span class="o">=</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-6"><code data-line-number="6"></code></a></td><td class="code"><code><a id="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-6" name="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-6"></a><span class="na">ExecStart</span><span class="o">=</span><span class="s">/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:2375 --containerd=/run/containerd/containerd.sock</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-7"><code data-line-number="7"></code></a></td><td class="code"><code><a id="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-7" name="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-7"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-8"><code data-line-number="8"></code></a></td><td class="code"><code><a id="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-8" name="code_74e3f0c1e66ee254ad53204ffcc30ad66875b005-8"></a><span class="c1">### Edits below this comment will be discarded</span>
</code></td></tr></table></div>
<p>➡️ We’re done with the WSL setup, so let’s restart WSL and make sure Docker is working:</p>
<div class="code"><table class="codetable"><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-1"><code data-line-number="1"></code></a></td><td class="code"><code><a id="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-1" name="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-1"></a>&gt; wsl --shutdown
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-2"><code data-line-number="2"></code></a></td><td class="code"><code><a id="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-2" name="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-2"></a>&gt; wsl docker run --rm hello-world
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-3"><code data-line-number="3"></code></a></td><td class="code"><code><a id="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-3" name="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-3"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-4"><code data-line-number="4"></code></a></td><td class="code"><code><a id="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-4" name="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-4"></a>Hello from Docker!
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-5"><code data-line-number="5"></code></a></td><td class="code"><code><a id="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-5" name="code_2c45ca58d73b1fb5d17bb46934173dcfb55b65e3-5"></a>This message shows that your installation appears to be working correctly.
</code></td></tr></table></div>
<h2 id="windows-setup">Windows setup</h2>
<p>➡️ Download the latest version of the <a href="https://download.docker.com/win/static/stable/x86_64/">Docker binaries</a>. Extract <code>docker.exe</code> and put it somewhere on your Windows <code>PATH</code>. I have a <code>~\Tools\bin</code> folder for things like that.</p>
<p>We need to tell the Docker CLI where to look for Docker. The easiest way to do this is to set the <code>DOCKER_HOST</code> environment variable. This might not be the cleanest way if you want to work with Windows containers or Docker Desktop, but you don’t, so we don’t need to bother with anything nicer.</p>
<p>➡️ Press the Start key, type <em>environment variables</em> (or the equivalent phrase in your Windows language) and open the environment variables editor. Add an environment variable named <code>DOCKER_HOST</code> with the value <code>tcp://127.0.0.1:2375</code>.</p>
<p>➡️ Restart your Terminal. In one tab, run a WSL shell. In another, run PowerShell (or cmd):</p>
<div class="code"><table class="codetable"><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-1"><code data-line-number="1"></code></a></td><td class="code"><code><a id="code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-1" name="code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-1"></a>&gt; docker run -it --rm hello-world
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-2"><code data-line-number="2"></code></a></td><td class="code"><code><a id="code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-2" name="code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-2"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-3"><code data-line-number="3"></code></a></td><td class="code"><code><a id="code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-3" name="code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-3"></a>Hello from Docker!
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-4"><code data-line-number="4"></code></a></td><td class="code"><code><a id="code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-4" name="code_71178a5b7990c2f9c7621fcb3b389c2f84e8c174-4"></a>This message shows that your installation appears to be working correctly.
</code></td></tr></table></div>
<h2 id="optional-docker-compose">Optional: Docker Compose</h2>
<p>Docker Compose is a plugin for Docker CLI, and it not included in the Docker binary we’ve installed on Windows. It is quite easy to add it in if you want.</p>
<p>➡️ Download the latest version of the <a href="https://github.com/docker/compose/releases/latest">Docker Compose binary</a> (<code>docker-compose-windows-x86_64.exe</code>). Move it to <code>~\.docker\cli-plugins\docker-compose.exe</code>.</p>
<div class="highlight"><pre><span></span>&gt; mkdir ~\.docker\cli-plugins
&gt; mv ~\Downloads\docker-compose-windows-x86_64.exe ~\.docker\cli-plugins\docker-compose.exe
</pre></div>

<p>Let’s test it out:</p>
<div class="highlight"><pre><span></span>&gt; docker compose version
Docker Compose version v5.1.0
</pre></div>

<h2 id="optional-wsl-vm-management">Optional: WSL VM management</h2>
<p>WSL does not automatically start the Linux VM. And it kills it if no user process is running inside of it.</p>
<p>If you’re fine with having a WSL terminal open while you’re working with Docker, you don’t need to do anything. But if you don’t want to see a WSL terminal, <a href="https://askubuntu.com/questions/1177273/is-there-an-easy-way-to-have-wsl-ubuntu-services-start-automatically-on-windows">make Windows start WSL when you log in</a> and set a really large <em>VM Idle Timeout</em> in the <em>Optional Features</em> tab of the <em>WSL Settings</em> app. The maximum value accepted by the GUI<a id="fnref:1" href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#fn:1" class="footnote-ref"><sup>1</sup></a> is the maximum value a 32-bit integer can represent, i.e. 2147483647 ms (24 days). You can also manually add the option to <code>~\.wslconfig</code>:</p>
<div class="highlight"><pre><span></span><span class="k">[wsl2]</span>
<span class="na">vmIdleTimeout</span><span class="o">=</span><span class="s">2147483647</span>
</pre></div>

<div class="footnotes">
<hr>
<ol>
<li id="fn:1">
<p>If you try to input a larger number, the app just crashes. That’s what you get when you fire your QA department and let AI take over coding.<a href="https://chriswarrick.com/blog/2026/03/04/docker-in-wsl-a-no-frills-guide/#fnref:1" class="footnote-back-ref">&#8617;</a></p>
</li>
</ol>
</div>
]]></content:encoded><category>Programming</category><category>Docker</category><category>Linux</category><category>Windows</category><category>WSL</category></item><item><title>Deploying Python Web Applications with Docker</title><dc:creator>Chris Warrick</dc:creator><link>https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/</link><pubDate>Fri, 06 Feb 2026 19:45:00 GMT</pubDate><guid>https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/</guid><description>Ten years ago, almost to the day, I wrote a very long blog post titled Deploying Python Web Applications with nginx and uWSGI Emperor. This week, I’ve migrated the Python web applications hosted on my VPS to Docker containers. Here are some reasons why, and all my Docker files to help you do this on your server.
</description><content:encoded><![CDATA[<p>Ten years ago, almost to the day, I wrote a very long blog post titled <a href="https://chriswarrick.com/blog/2016/02/10/deploying-python-web-apps-with-nginx-and-uwsgi-emperor/">Deploying Python Web Applications with nginx and uWSGI Emperor</a>. This week, I’ve migrated the Python web applications hosted on my VPS to Docker containers. Here are some reasons why, and all my Docker files to help you do this on your server.</p>



<p>You can jump to the <a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#scripts-and-configuration-files">scripts and configuration files</a> if you don’t care about the theory and just want to see the end result.</p>
<h2 id="why-docker">Why Docker?</h2>
<p>Docker is a technology that has taken the software engineering world by storm. The main promise is isolation: a Docker container that works on an x86_64 Linux machine will work on any x86_64 Linux machine in the same way. Want to quickly set up PostgreSQL for testing? Just run <code>docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d --restart=unless-stopped postgres</code> and wait a few seconds. Docker is great for deployment as well as production deployments, and it even supports Windows Server containers these days (whether or not this is a pleasant experience is a different question).</p>
<p>Of course, there is a trade-off: running something in a Docker container requires more disk space than running the same software outside of Docker would. This is because Docker containers have their own copies of <em>everything</em>: the C library, the shell, core commands, and the runtime of your favorite language. But this is not a bug, it’s a feature.</p>
<p>If you read <a href="https://chriswarrick.com/blog/2016/02/10/deploying-python-web-apps-with-nginx-and-uwsgi-emperor/">the nginx/uWSGI Emperor guide</a> I wrote ten years ago, you might notice there are many cases where the configuration differs depending on the Linux distribution in use. Some distributions made logging an optional feature, others have it built in. Each distribution has a slightly different directory structure, and different users and groups for Web services. Some distros did not ship systemd service files. Red Hat is still pushing SELinux.</p>
<p>But uWSGI is not the only pain point. There’s also the system Python. Every distribution treats it differently and applies different customizations. Arch maps <code>python</code> to <code>python3</code>, but other distributions do not. Arch and Fedora ship a single Python package, while Debian/Ubuntu have many split packages. Taking a dependency on the system Python also makes distro upgrades harder: if the system Python is upgraded, the virtual environment needs to be recreated. (Hope you have an up-to-date <code>requirements.txt</code>!)</p>
<h2 id="should-everything-be-in-docker">Should everything be in Docker?</h2>
<p>It depends on your definition of <em>everything</em>. I ended up with only one non-dockerized application (which requires access to resources that cannot easily be provided to it when it is in a container): an <a href="https://dotnet.microsoft.com/en-us/apps/aspnet">ASP.NET Core</a> Minimal API compiled with <a href="https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/">Native AOT</a>, so its maintenance burden is essentially zero. Except for that app, all web applications on my VPS, whether written in PHP, Python, or .NET, run in Docker. I don't need to figure out how to make PHP happy; I use a container image in which someone else had done the hard parts for me. I don't need to maintain Python virtual environments; they can just live inside containers. The maintenance burden for .NET is smaller, but containers still prevent issues that could be caused by removing an old version of .NET, for example. (Those apps are ASP.NET Core MVC, so they are not compatible with Native AOT.)</p>
<p>But I am not running the Web-facing nginx instance in Docker. Similarly, I’ve kept PostgreSQL outside of Docker, and I’ve just un-dockerized a MariaDB instance. The main difference here is that I can <code>apt install nginx</code> and get a supported and secure build, with default configuration that might be more reasonable than the default. (But then again, <code>apt install python3</code> gets you a fairly mediocre build.)</p>
<p>For the Python dockerization project, my requirements are fairly simple. The Docker container only needs Python, a venv with dependencies installed, and all data files of the app. The database exists outside of Docker, and I’ve already configured PostgreSQL to listen on an address accessible from within Docker (but of course, not from the public Internet). Because Django and Python have abysmal performance, static files must be served by nginx. Since I don’t want a dedicated nginx in a Docker container, the easiest solution is to mount a folder as a volume: Django runs <code>collectstatic</code> inside the container to write static files there, and the host nginx serves them.</p>
<h2 id="what-should-be-in-docker">What should be in Docker?</h2>
<p>There are four things that we need to put in our Docker container: Linux, Python, a venv, and a WSGI server.</p>
<h3 id="linux-and-python-base-image">Linux and Python (base image)</h3>
<p>The choice of a base image can affect a few things about the Docker experience. For Python, the most commonly used image is the one prepared by Docker, Inc. simply named <code>python</code>. That image has three versions, or tags in Docker parlance:</p>
<ul>
<li><code>python:3.14</code> (the default), which is based on Debian (1.12GB)</li>
<li><code>python:3.14-slim</code>, which is based on Debian but with less cruft (119MB)</li>
<li><code>python:3.14-alpine</code>, which is bvased on Alpine Linux (47.4MB)</li>
</ul>
<p>Alpine Linux images are really small, but with the caveat that they are based on the <code>musl</code> libc instead of GNU <code>glibc</code>, which means most binaries, including <code>manylinux</code> binary wheels, do not work, and special builds (<code>musllinux</code> binary wheels in this case) are required. I started with the Debian-based images (the default one for build, the slim one for production), but I switched to <code>python:3.14-alpine</code>, as the only binary dependency I have is <code>psycopg2</code>, which I build from source, but there are <code>musllinux</code> wheels of <code>psycopg2-binary</code> available.</p>
<h3 id="virtual-environments-and-dependency-management">Virtual environments and dependency management</h3>
<p>Python packaging is still a mess. I don’t feel like using the VC-backed <code>uv</code>, and the other big tools (like <code>poetry</code> or <code>pipenv</code>) introduce too much magic and bloat. All I need is a <code>requirements.txt</code> file I can install with pip into a venv, but without having to manually track version numbers. For that, <a href="https://github.com/jazzband/pip-tools"><code>pip-compile</code> from <code>pip-tools</code></a> is a great option. It takes a <code>requirements.in</code> file with package names and optional version ranges, and produces a <code>requirements.txt</code> with all dependencies (including transitive dependencies) pinned to exact versions. It doesn’t get much simpler than that.</p>
<p>There is one issue: the <code>requirements.txt</code> files produced by <code>pip-compile</code> are specific to the environment in which it was executed. So if you want a <code>requirements.txt</code> for Linux and Python 3.14, you must run <code>pip-compile</code> on Linux with Python 3.14. While this does not matter much for this project (it has very simple dependencies), I wanted to ensure the tool runs with the same Python version the container will use, and to allow building the image without having <code>pip-compile</code> installed on the development machine.</p>
<p>So, I quickly hacked together a tool unoriginally named <a href="https://github.com/Kwpolska/docker-pip-compile"><code>docker-pip-compile</code></a>. It’s a five-line <code>Dockerfile</code> and a slightly longer shell script to help run it. That way, dependencies can be updated and the entire project can be built even without a functional system Python. The only catch here (and the reason for the hackiest line in the Dockerfile) is the fact that the package must be buildable in the environment where <code>pip-compile</code> runs, so I had to install <code>libpq</code> (the PostgreSQL client library) there.</p>
<h3 id="wsgi-server">WSGI server</h3>
<p>The old post used uWSGI (it’s even mentioned in the title). Sadly, <a href="https://github.com/unbit/uwsgi/commit/5838086dd4490b8a55ff58fc0bf0f108caa4e079">uWSGI has been in maintenance mode since 2022</a>. On the other hand, <a href="https://github.com/benoitc/gunicorn">gunicorn</a> is doing pretty well, so I used that. I also decided to add <a href="https://uvicorn.dev/">uvicorn</a> to the mix, because why not.</p>
<h2 id="scripts-and-configuration-files">Scripts and configuration files</h2>
<p>You might be able to find a more up-to-date version of those scripts in the <a href="https://github.com/getnikola/nikola-users/tree/master/docker">nikola-users</a> repository.</p>
<h3 id="dockerfile">Dockerfile</h3>
<p>The Dockerfile is pretty straightforward. To save a little disk space, I use a multi-stage build. The build stage sets up a virtual environment, installs packages into it, and copies files into <code>/app</code>. The final stage installs <code>libpq</code> (the PostgreSQL client library, needed for <code>psycopg2</code>) and copies <code>/venv</code> and <code>/app</code> from the build stage. (The disk space savings come from not having <code>build-base</code> and <code>libpq-dev</code> in the final image.)</p>
<div class="code"><table class="codetable"><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-1"><code data-line-number=" 1"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-1" name="code_381600d5da99646e75aaa66100a72b972eb5088c-1"></a><span class="k">FROM</span><span class="w"> </span><span class="s">python:3.14-alpine</span><span class="w"> </span><span class="k">AS</span><span class="w"> </span><span class="s">build</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-2"><code data-line-number=" 2"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-2" name="code_381600d5da99646e75aaa66100a72b972eb5088c-2"></a><span class="k">WORKDIR</span><span class="w"> </span><span class="s">/app</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-3"><code data-line-number=" 3"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-3" name="code_381600d5da99646e75aaa66100a72b972eb5088c-3"></a><span class="k">RUN</span><span class="w"> </span>apk<span class="w"> </span>add<span class="w"> </span>build-base<span class="w"> </span>libpq<span class="w"> </span>libpq-dev
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-4"><code data-line-number=" 4"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-4" name="code_381600d5da99646e75aaa66100a72b972eb5088c-4"></a><span class="k">RUN</span><span class="w"> </span>python<span class="w"> </span>-m<span class="w"> </span>venv<span class="w"> </span>/venv<span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span>/venv/bin/python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>--no-cache-dir<span class="w"> </span>-U<span class="w"> </span>pip
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-5"><code data-line-number=" 5"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-5" name="code_381600d5da99646e75aaa66100a72b972eb5088c-5"></a><span class="k">COPY</span><span class="w"> </span>requirements.txt<span class="w"> </span>/app
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-6"><code data-line-number=" 6"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-6" name="code_381600d5da99646e75aaa66100a72b972eb5088c-6"></a><span class="k">RUN</span><span class="w"> </span>/venv/bin/pip<span class="w"> </span>install<span class="w"> </span>--no-cache-dir<span class="w"> </span>-r<span class="w"> </span>requirements.txt
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-7"><code data-line-number=" 7"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-7" name="code_381600d5da99646e75aaa66100a72b972eb5088c-7"></a><span class="k">COPY</span><span class="w"> </span>nikolausers<span class="w"> </span>/app/nikolausers
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-8"><code data-line-number=" 8"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-8" name="code_381600d5da99646e75aaa66100a72b972eb5088c-8"></a><span class="k">COPY</span><span class="w"> </span>sites<span class="w"> </span>/app/sites
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-9"><code data-line-number=" 9"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-9" name="code_381600d5da99646e75aaa66100a72b972eb5088c-9"></a><span class="k">COPY</span><span class="w"> </span>templates<span class="w"> </span>/app/templates
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-10"><code data-line-number="10"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-10" name="code_381600d5da99646e75aaa66100a72b972eb5088c-10"></a><span class="k">COPY</span><span class="w"> </span>manage.py<span class="w"> </span>docker/docker-entrypoint.sh<span class="w"> </span>/app/
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-11"><code data-line-number="11"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-11" name="code_381600d5da99646e75aaa66100a72b972eb5088c-11"></a><span class="k">RUN</span><span class="w"> </span>chmod<span class="w"> </span>+x<span class="w"> </span>/app/docker-entrypoint.sh
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-12"><code data-line-number="12"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-12" name="code_381600d5da99646e75aaa66100a72b972eb5088c-12"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-13"><code data-line-number="13"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-13" name="code_381600d5da99646e75aaa66100a72b972eb5088c-13"></a><span class="k">FROM</span><span class="w"> </span><span class="s">python:3.14-alpine</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-14"><code data-line-number="14"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-14" name="code_381600d5da99646e75aaa66100a72b972eb5088c-14"></a><span class="k">WORKDIR</span><span class="w"> </span><span class="s">/app</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-15"><code data-line-number="15"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-15" name="code_381600d5da99646e75aaa66100a72b972eb5088c-15"></a><span class="k">RUN</span><span class="w"> </span>apk<span class="w"> </span>add<span class="w"> </span>libpq
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-16"><code data-line-number="16"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-16" name="code_381600d5da99646e75aaa66100a72b972eb5088c-16"></a><span class="k">COPY</span><span class="w"> </span>--from<span class="o">=</span>build<span class="w"> </span>/venv<span class="w"> </span>/venv
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-17"><code data-line-number="17"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-17" name="code_381600d5da99646e75aaa66100a72b972eb5088c-17"></a><span class="k">COPY</span><span class="w"> </span>--from<span class="o">=</span>build<span class="w"> </span>/app<span class="w"> </span>/app
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_381600d5da99646e75aaa66100a72b972eb5088c-18"><code data-line-number="18"></code></a></td><td class="code"><code><a id="code_381600d5da99646e75aaa66100a72b972eb5088c-18" name="code_381600d5da99646e75aaa66100a72b972eb5088c-18"></a><span class="k">ENTRYPOINT</span><span class="w"> </span><span class="p">[</span><span class="s2">&quot;/app/docker-entrypoint.sh&quot;</span><span class="p">]</span>
</code></td></tr></table></div>
<h3 id="docker-entrypoint.sh">docker-entrypoint.sh</h3>
<p>The entrypoint is fairly simple as well. Before starting gunicorn, we need to run migrations and collect static files. To avoid repeating this on container restarts, we create a marker file inside the container to indicate whether setup has already completed. I use three workers, which should be enough for those sites.</p>
<div class="code"><table class="codetable"><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_77ec481338d658dd68a97d1b6cf252576c12e963-1"><code data-line-number="1"></code></a></td><td class="code"><code><a id="code_77ec481338d658dd68a97d1b6cf252576c12e963-1" name="code_77ec481338d658dd68a97d1b6cf252576c12e963-1"></a><span class="ch">#!/bin/sh</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_77ec481338d658dd68a97d1b6cf252576c12e963-2"><code data-line-number="2"></code></a></td><td class="code"><code><a id="code_77ec481338d658dd68a97d1b6cf252576c12e963-2" name="code_77ec481338d658dd68a97d1b6cf252576c12e963-2"></a><span class="nv">statefile</span><span class="o">=</span>/tmp/migrated
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_77ec481338d658dd68a97d1b6cf252576c12e963-3"><code data-line-number="3"></code></a></td><td class="code"><code><a id="code_77ec481338d658dd68a97d1b6cf252576c12e963-3" name="code_77ec481338d658dd68a97d1b6cf252576c12e963-3"></a><span class="k">if</span><span class="w"> </span><span class="o">[</span><span class="w"> </span>!<span class="w"> </span>-f<span class="w"> </span><span class="s2">&quot;</span><span class="nv">$statefile</span><span class="s2">&quot;</span><span class="w"> </span><span class="o">]</span><span class="p">;</span><span class="w"> </span><span class="k">then</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_77ec481338d658dd68a97d1b6cf252576c12e963-4"><code data-line-number="4"></code></a></td><td class="code"><code><a id="code_77ec481338d658dd68a97d1b6cf252576c12e963-4" name="code_77ec481338d658dd68a97d1b6cf252576c12e963-4"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span>/venv/bin/python<span class="w"> </span>manage.py<span class="w"> </span>collectstatic<span class="w"> </span>--noinput
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_77ec481338d658dd68a97d1b6cf252576c12e963-5"><code data-line-number="5"></code></a></td><td class="code"><code><a id="code_77ec481338d658dd68a97d1b6cf252576c12e963-5" name="code_77ec481338d658dd68a97d1b6cf252576c12e963-5"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span>/venv/bin/python<span class="w"> </span>manage.py<span class="w"> </span>migrate<span class="w"> </span>--noinput
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_77ec481338d658dd68a97d1b6cf252576c12e963-6"><code data-line-number="6"></code></a></td><td class="code"><code><a id="code_77ec481338d658dd68a97d1b6cf252576c12e963-6" name="code_77ec481338d658dd68a97d1b6cf252576c12e963-6"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span>touch<span class="w"> </span><span class="s2">&quot;</span><span class="nv">$statefile</span><span class="s2">&quot;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_77ec481338d658dd68a97d1b6cf252576c12e963-7"><code data-line-number="7"></code></a></td><td class="code"><code><a id="code_77ec481338d658dd68a97d1b6cf252576c12e963-7" name="code_77ec481338d658dd68a97d1b6cf252576c12e963-7"></a><span class="k">fi</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_77ec481338d658dd68a97d1b6cf252576c12e963-8"><code data-line-number="8"></code></a></td><td class="code"><code><a id="code_77ec481338d658dd68a97d1b6cf252576c12e963-8" name="code_77ec481338d658dd68a97d1b6cf252576c12e963-8"></a><span class="nb">exec</span><span class="w"> </span>/venv/bin/python<span class="w"> </span>-m<span class="w"> </span>gunicorn<span class="w"> </span>--bind<span class="w"> </span><span class="m">0</span>.0.0.0:6868<span class="w"> </span>nikolausers.asgi:application<span class="w"> </span>-k<span class="w"> </span>uvicorn_worker.UvicornWorker<span class="w"> </span>-w<span class="w"> </span><span class="m">3</span>
</code></td></tr></table></div>
<h3 id="docker-compose.yml">docker-compose.yml</h3>
<p>I mentioned that only one service runs inside Docker, since nginx and PostgreSQL live outside. Docker Compose may feel unnecessary with just one service, but it is still a convenient way to keep the required configuration in a file.</p>
<div class="code"><table class="codetable"><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-1"><code data-line-number=" 1"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-1" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-1"></a>services:
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-2"><code data-line-number=" 2"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-2" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-2"></a><span class="w">&nbsp;&nbsp;</span>nikolausers:
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-3"><code data-line-number=" 3"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-3" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-3"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span>restart:<span class="w"> </span>unless-stopped
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-4"><code data-line-number=" 4"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-4" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-4"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span>image:<span class="w"> </span>nikolausers:latest
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-5"><code data-line-number=" 5"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-5" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-5"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span>ports:
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-6"><code data-line-number=" 6"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-6" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-6"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>-<span class="w"> </span><span class="m">127</span>.0.0.1:6868:6868
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-7"><code data-line-number=" 7"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-7" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-7"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span>user:<span class="w"> </span><span class="s2">&quot;33:33&quot;</span><span class="w"> </span><span class="c1"># www-data on Debian</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-8"><code data-line-number=" 8"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-8" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-8"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span>environment:
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-9"><code data-line-number=" 9"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-9" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-9"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="c1">#SECRET_KEY: &quot;&quot;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-10"><code data-line-number="10"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-10" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-10"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="c1">#DB_NAME: &quot;&quot;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-11"><code data-line-number="11"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-11" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-11"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="c1">#DB_USER: &quot;&quot;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-12"><code data-line-number="12"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-12" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-12"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="c1">#DB_PASSWORD: &quot;&quot;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-13"><code data-line-number="13"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-13" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-13"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="c1">#DB_HOST: &quot;&quot;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-14"><code data-line-number="14"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-14" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-14"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="c1">#EMAIL_HOST: &quot;&quot;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-15"><code data-line-number="15"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-15" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-15"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span>volumes:
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_0df510911c34864d8036ab1906f2ab9cb403c19f-16"><code data-line-number="16"></code></a></td><td class="code"><code><a id="code_0df510911c34864d8036ab1906f2ab9cb403c19f-16" name="code_0df510911c34864d8036ab1906f2ab9cb403c19f-16"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>-<span class="w"> </span>./static:/app/static
</code></td></tr></table></div>
<h3 id="nginx">nginx</h3>
<p>The nginx configuration is as simple as it gets:</p>
<div class="code"><table class="codetable"><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-1"><code data-line-number=" 1"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-1" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-1"></a><span class="k">server</span><span class="w"> </span><span class="p">{</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-2"><code data-line-number=" 2"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-2" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-2"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="c1"># skip standard host config...</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-3"><code data-line-number=" 3"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-3" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-3"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-4"><code data-line-number=" 4"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-4" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-4"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kn">location</span><span class="w"> </span><span class="s">/</span><span class="w"> </span><span class="p">{</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-5"><code data-line-number=" 5"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-5" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-5"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kn">proxy_pass</span><span class="w"> </span><span class="s">http://127.0.0.1:6868/</span><span class="p">;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-6"><code data-line-number=" 6"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-6" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-6"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kn">include</span><span class="w"> </span><span class="s">proxy_params</span><span class="p">;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-7"><code data-line-number=" 7"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-7" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-7"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="p">}</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-8"><code data-line-number=" 8"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-8" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-8"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-9"><code data-line-number=" 9"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-9" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-9"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kn">location</span><span class="w"> </span><span class="s">/static</span><span class="w"> </span><span class="p">{</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-10"><code data-line-number="10"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-10" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-10"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="kn">alias</span><span class="w"> </span><span class="s">/srv/users.getnikola.com/static</span><span class="p">;</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-11"><code data-line-number="11"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-11" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-11"></a><span class="w">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="p">}</span>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/#code_8c7aabea1826b4da5011effecea7431edf34cb4e-12"><code data-line-number="12"></code></a></td><td class="code"><code><a id="code_8c7aabea1826b4da5011effecea7431edf34cb4e-12" name="code_8c7aabea1826b4da5011effecea7431edf34cb4e-12"></a><span class="p">}</span>
</code></td></tr></table></div>
<h2 id="conclusion">Conclusion</h2>
<p>In just two evenings, I got rid of the venv and system Python maintenance burden. When I upgrade to Ubuntu 26.04 in a few months, my Python apps will just work with no extra steps needed. Docker is a lot of fun.</p>
]]></content:encoded><category>Python</category><category>Django</category><category>Docker</category><category>gunicorn</category><category>Internet</category><category>Linux</category><category>nginx</category><category>Python</category></item><item><title>Distro Hopping, Server Edition</title><dc:creator>Chris Warrick</dc:creator><link>https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/</link><pubDate>Sun, 09 Nov 2025 18:00:00 GMT</pubDate><guid>https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/</guid><description>I’ve recently migrated my VPS from Fedora to Ubuntu. Here’s a list of things that might be useful to keep in mind before, during, and after a migration of a server that hosts publicly accessible Web sites and applications, as well as other personal services, and how to get rid of the most annoying parts of Ubuntu.
</description><content:encoded><![CDATA[<p>I’ve recently migrated my VPS from Fedora to Ubuntu. Here’s a list of things that might be useful to keep in mind before, during, and after a migration of a server that hosts publicly accessible Web sites and applications, as well as other personal services, and how to get rid of the most annoying parts of Ubuntu.</p>



<h2 id="why-switch">Why switch?</h2>
<p>Fedora is a relatively popular distro, so it’s well supported by software vendors. Its packagers adopt a no-nonsense approach, making very little changes that deviate from the upstream.</p>
<p>Ubuntu is not my favorite distro, far from it. While it is perhaps the most popular distro out there, its packages contain many more patches compared to Fedora, and Canonical (the company behind Ubuntu) are famous for betting on the wrong horse (Unity, upstart, Mir…). But one thing Ubuntu does well is stability. Fedora makes releases every 6 months, and those releases are supported for just 13 months, which means upgrading at least every year. Every upgrade may introduce incompatibilities, almost every upgrade requires recreating Python venvs. That gets boring fast, and it does not necessarily bring benefits. Granted, the Fedora system upgrade works quite well, and I upgraded through at least eight releases without a re-install, but I would still prefer to avoid it. That’s why I went with Ubuntu LTS, which is supported for five years, with a new release every two years, but which still comes with reasonably new software (and with many third-party repositories if something is missing or outdated).</p>
<h2 id="test-your-backups">Test your backups</h2>
<p>I have a backup “system” that’s a bunch of Bash scripts. After upgrading one of the services that is being backed up, the responsible script started crashing, and thus backups stopped working. Another thing that broke was e-mails from cron, so I didn’t know anything was wrong.</p>
<p>While I do have full disk backups enabled at <a href="https://hetzner.cloud/?ref=Qy1lehF8PwzP">Hetzner</a> <em>(disclaimer: referral link)</em>, my custom backups are more fine-grained (e.g. important configuration files, database dumps, package lists), so they are quite useful in migrating between OSes.</p>
<p>So, here’s a reminder not only to test your backups regularly, but also to make sure they are being created at all, and to make sure cron can send you logs somewhere you can see them.</p>
<p>Bonus cron tip: set <code>MAILFROM=</code> and <code>MAILTO=</code> in your crontab if your SMTP server does not like the values cron uses by default.</p>
<h2 id="think-about-ip-address-reassignment-or-pray-to-the-dns-gods">Think about IP address reassignment (or pray to the DNS gods)</h2>
<p>A new VPS or cloud server probably means a new IP address. But if you get a new IP address, that might complicate the migration of your publicly accessible applications. If you’re proxying all your Web properties through Cloudflare or something similar, that’s probably not an issue. But if you have a raw A record somewhere, things can get complicated. DNS servers and operating systems do a lot of caching. The conventional wisdom is to wait 24 or even 48 hours after changing DNS values. This might be true if your TTL is set to a long value, but if your TTL is short, the only worry are DNS servers that ignore TTL values and cache records for longer. If you plan a migration, it’s good to check your TTL well in advance, and not worry too much about broken DNS servers.</p>
<p>But you might not need a new IP. Carefully review your cloud provider’s IP management options before making any changes. Hetzner is more flexible than other hosts in this regard, as it is possible to <a href="https://docs.hetzner.com/cloud/servers/primary-ips/faq">move primary public IP addresses (not “floating” or “elastic” IPs) between servers</a>, as long as you’re okay with a few minutes’ downtime (you will need to shut down the source and destination servers).</p>
<p>If you’re not okay with any downtime, you would probably want to leverage the floating/elastic IP feature, or hope DNS propagates quickly enough.</p>
<h2 id="trim-the-fat">Trim the fat</h2>
<p>My VPS ran a lot of services I don’t need anymore, but never really got around to decommissioning. For example, I had a full Xfce install with VNC access (the VNC server was only running when needed). I haven’t actually used the desktop for ages, so I just dropped it.</p>
<p>I also had an OpenVPN setup. It was useful years ago, when mobile data allowances were much smaller and speeds much worse. These days, I don’t use public WiFi networks at all, unless I’m going abroad, and I just buy one month of <a href="https://mullvad.net/">Mullvad VPN</a> for €5 whenever that happens. So, add another service to the “do not migrate” list.</p>
<p>One thing that I could not just remove was the e-mail server. Many years ago, I ran a reasonably functional e-mail server on my VPS. I’ve since then migrated to <a href="https://www.zoho.com/mail/">Zoho Mail</a> (which costs €10.80/year), in part due to IP reputation issues after changing hosting providers, and also to avoid having to fight spam. When I did that, I kept Postfix around, but as a local server for things like cron or Django to send e-mail with, and I configured it to send all e-mails via Zoho. But I did not really want to move over all the configuration, hoping that Ubuntu’s Postfix packages can work with my hacked together config from Fedora. So I replaced the server with <a href="https://www.opensmtpd.org/">OpenSMTPD</a> (from the OpenBSD project), and all the Postfix configuration files with just one short configuration file:</p>
<div class="code"><table class="codetable"><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/#code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-1"><code data-line-number="1"></code></a></td><td class="code"><code><a id="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-1" name="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-1"></a>table aliases file:/etc/aliases
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/#code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-2"><code data-line-number="2"></code></a></td><td class="code"><code><a id="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-2" name="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-2"></a>table secrets file:/etc/mail-secrets
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/#code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-3"><code data-line-number="3"></code></a></td><td class="code"><code><a id="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-3" name="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-3"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/#code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-4"><code data-line-number="4"></code></a></td><td class="code"><code><a id="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-4" name="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-4"></a>listen on localhost
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/#code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-5"><code data-line-number="5"></code></a></td><td class="code"><code><a id="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-5" name="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-5"></a>listen on 172.17.0.1 # Docker
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/#code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-6"><code data-line-number="6"></code></a></td><td class="code"><code><a id="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-6" name="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-6"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/#code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-7"><code data-line-number="7"></code></a></td><td class="code"><code><a id="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-7" name="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-7"></a>action &quot;relay&quot; relay host smtp+tls://smtp@smtp.example.net:587 auth &lt;secrets&gt; mail-from &quot;@example.com&quot;
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/#code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-8"><code data-line-number="8"></code></a></td><td class="code"><code><a id="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-8" name="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-8"></a>
</code></td></tr><tr><td class="linenos linenodiv"><a href="https://chriswarrick.com/blog/2025/11/09/distro-hopping-server-edition/#code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-9"><code data-line-number="9"></code></a></td><td class="code"><code><a id="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-9" name="code_2c8287178270f9e6d85ad33ec63ce4e8cfae3d0b-9"></a>match from any for any action &quot;relay&quot;
</code></td></tr></table></div>
<h2 id="dockerize-everything">Dockerize everything…</h2>
<p>My server runs a few different apps, some of which are exposed on the public Internet, while some do useful work in the background. The services I have set up most recently are containerized with the help of Docker. The only Docker-based service that was stateful (and did not just use folders mounted as volumes) was a MariaDB database. Migrating that is straightforward with a simple dump-and-restore.</p>
<p>Of course, not everything on my server is in Docker. The public-facing nginx install isn’t, and neither is PostgreSQL (but that was also a quick dump-and-restore migration with some extra steps).</p>
<h2 id="especially-python">…especially Python</h2>
<p>But then, there are the Python apps. Python the language is cool (if a little slow), but the packaging story is a <a href="https://chriswarrick.com/blog/2023/01/15/how-to-improve-python-packaging/">total</a> dumpster <a href="https://chriswarrick.com/blog/2024/01/15/python-packaging-one-year-later/">fire</a>.</p>
<p>By the way, here’s a quick recap of 2024/2025 in Python packaging: the most hyped Python package manager (<code>uv</code>) is written in Rust, which screams “Python is a toy language in which you can’t even write a tool as simple as a package manager”. (I know, dependency resolution is computationally expensive, so doing <em>that</em> in Rust makes sense, but everything else could easily be done in pure Python. And no, the package manager should not manage Python installs.) Of course, almost all the other contenders listed in my 2023 post are still being developed. On the standards front, the community finally produced a lockfile standard after years of discussions.</p>
<p>Anyway, I have three Python apps. One of them is <a href="https://isso-comments.de/">Isso</a>, which is providing the comments box below this post. I used to run a modified version of Isso a long time ago, but I don’t need to anymore. I looked at the docs, and they offer <a href="https://isso-comments.de/docs/reference/installation/#using-docker">a pre-built Docker image</a>, which means I could just quickly deploy it on my server with Docker and skip the pain of managing Python environments.</p>
<p>The other two apps are Django projects built by yours truly. They are not containerized, they exist in venvs created using the system Python. Moving venvs between machines is generally impossible, so I had to re-create them. Of course, I hit a deprecation, because the Python maintainers (especially in the packaging world) does not understand their responsibility as maintainers of the most popular programming language. This time, it was caused by <a href="https://github.com/pypa/pip/issues/11457">an old editable install with setuptools (using setup.py develop, not PEP 660)</a>, and installs with more recent pip/setuptools versions would not have this error… although <a href="https://discuss.python.org/t/do-we-want-to-keep-the-build-system-default-for-pyproject-toml/104759">some people want to remove the fallback to setuptools if there is no pyproject.toml</a>, so you need to stay up to date with the whims of the Python packaging industry if you want to use Python software.</p>
<p><strong>Update 2026-02-06:</strong> <a href="https://chriswarrick.com/blog/2026/02/06/deploying-python-web-applications-with-docker/">I migrated the two Django apps to Docker and wrote a post about it.</a></p>
<h2 id="dont-bother-with-ufw">Don’t bother with ufw</h2>
<p>Ubuntu ships with <code>ufw</code>, the “uncomplicated firewall”, in the default install. I was previously using <code>firewalld</code>, a Red Hat-adjacent project, but I decided to give ufw a try. Since if it’s part of the default install, it might be supported better by the system.</p>
<p>It turns out that Docker and ufw <a href="https://docs.docker.com/engine/network/packet-filtering-firewalls/#docker-and-ufw">don’t play together</a>. <a href="https://github.com/chaifeng/ufw-docker?tab=readme-ov-file#solving-ufw-and-docker-issues">Someone has built a set of rules that are supposed to fix it</a>, but that did not work for me.</p>
<p>Docker <a href="https://docs.docker.com/engine/network/packet-filtering-firewalls/#integration-with-firewalld">does integrate with firewalld</a>, and Ubuntu has packages for it, so I just installed it, enabled the services that need to be publicly available and things were working again.</p>
<p><em>Update (2025-11-23):</em> The iptables integration was not very stable on my Ubuntu system, so I disabled the iptables integration and switched to <a href="https://dev.to/soerenmetje/how-to-secure-a-docker-host-using-firewalld-2joo">a simpler config in firewalld only</a>.</p>
<h2 id="kill-the-ads-and-other-nonsense-too">Kill the ads (and other nonsense too)</h2>
<p>Red Hat makes money by selling a stable OS with at least 10 years of support to enterprises, and their free offering is Fedora, with just 13 months of support; RHEL releases are branched off from Fedora. SUSE also sells SUSE Linux Enterprise and has openSUSE as the free offering (but the relationship between the paid and free version is more complicated).</p>
<p>Ubuntu chose a different monetization strategy: the enterprise offering is the same OS as the free offering, but it gets extra packages and extra updates. The free OS advertises the paid services. It is fairly simple to get rid of them all:</p>
<div class="highlight"><pre><span></span>sudo apt autoremove ubuntu-pro-client
sudo chmod -x /etc/update-motd.d/*
</pre></div>

<p>Also, Ubuntu installs snap by default. Snap is a terrible idea. Luckily, there are no snaps installed by default on a Server install, so we can just remove <code>snapd</code>. We’ll also remove <code>lxd-installer</code> to save ~25 kB of disk space, since the installer requires snap, and lxd is another unsuccessful Canonical project.</p>
<div class="highlight"><pre><span></span>sudo apt autoremove snapd lxd-installer
</pre></div>

<h2 id="the-cost-of-downgrading">The cost of downgrading</h2>
<p>Going from Fedora 42 (April 2025) to Ubuntu 24.04 (April 2024) means some software will be downgraded in the process. In general, this does not matter, as most software does not mind downgrades as much. One notable exception is WeeChat, the IRC client, whose config files are versioned, and Ubuntu’s version is not compatible with the one in Fedora. But here’s where Ubuntu’s popularity shines: <a href="https://weechat.org/download/debian/">WeeChat has its own repositories for Debian and Ubuntu</a>, so I could just get the latest version without building it myself or trying to steal packages from a newer version.</p>
<p>Other than WeeChat, I haven’t experienced any other issues with software due to a downgrade. Some of it is luck (or not using new/advanced features), some of it is software caring about backwards compatibility.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Was it worth it? Time will tell. Upgrading Fedora itself was not that hard, and I expect Ubuntu upgrades to be OK too — the annoying part was cleaning up and getting things to work after the upgrade, and the switch means I will have to do it only every 2-4 years instead of every 6-12 months.</p>
<p>The switchover took a few hours, especially since I didn’t have much up-to-date documentation of what is actually installed and running, and there are always the minor details where distros differ that may require adjusting to. I think a migration like this is worth trying if rolling-release or frequently-released distros are too unstable for your needs.</p>
]]></content:encoded><category>Linux</category><category>Django</category><category>Docker</category><category>Fedora</category><category>Linux</category><category>Python</category><category>Ubuntu</category></item></channel></rss>